flyctl: command not found

I use flyctl through Ubuntu in WSL2, installed via curl -L https://fly.io/install.sh | sh. After successful installation, I follow the instructions to add the directory to $HOME/.bash_profile:

export FLYCTL_INSTALL="/home/bman/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"

Everything works as normal until I close the WSL2 window. When I open a new WSL2 window, I receive flyctl: command not found and have to reinstall flyctl again.

What can I do to make the installation persistent?

Hmmm…looks like your .bash_profile is probably not being read when your terminal is being started. I believe a login shell with “bash -l” or moving the installation command in .bashrc may work.

I thought the export lines were being added to my profile, but they weren’t. In my WSL2 instance, the file is ~/.profile, not ~/.bash_profile. I manually added:

export FLYCTL_INSTALL="/home/bman/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"

to ~/.profile and that fixed the problem. I realize this isn’t a fly.io issue but it’s a simple gotcha that might help someone else.

3 Likes

I am running Ubuntu 20.04.4 LTS and was facing this issue. By adding the below commands at the end of the .bashrc file by opening it in the nano editor I was able to fix it

export FLYCTL_INSTALL="/home/mubashir/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"
1 Like