Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flyctl install script mistakenly thinks that the binary is on the PATH on Codespaces Ubuntu #733

Open
lpil opened this issue Jan 13, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@lpil
Copy link

lpil commented Jan 13, 2022

Describe the bug

Hello! I just ran curl -L https://fly.io/install.sh | sh on a new Ubuntu box and this happened

** Command output: **

curl -L https://fly.io/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1412    0  1412    0     0  23932      0 --:--:-- --:--:-- --:--:-- 23932

######################################################################## 100.0%##O#- #                                                                       
WARN no config file found at /home/codespace/.fly/config.yml
set channel to shell
flyctl was installed successfully to /home/codespace/.fly/bin/flyctl
Run 'flyctl --help' to get started

$ flyctl
bash: flyctl: command not found

Looking at the script I think the issue may be this check here:

echo "flyctl was installed successfully to $exe"
if command -v flyctl >/dev/null; then
	echo "Run 'flyctl --help' to get started"
else
	case $SHELL in
	/bin/zsh) shell_profile=".zshrc" ;;
	*) shell_profile=".bash_profile" ;;
	esac
	echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
	echo "  export FLYCTL_INSTALL=\"$flyctl_install\""
	echo "  export PATH=\"\$FLYCTL_INSTALL/bin:\$PATH\""
	echo "Run '$exe --help' to get started"
fi

It uses command -v flyctl to test if flyctl is on the PATH, but it mistakenly thinks it is because while it is not in the PATH, it is in the cwd when command -v flyctl is run, so flyctl successfully executes. Once the script exits we're no longer in the flyctl bin directory, so it no longer works.

If I follow the instructions in the other branch of the if statement it does work.

@lpil lpil added the bug Something isn't working label Jan 13, 2022
@lpil lpil changed the title flyctl install script fails to add binary to PATH flyctl install script fails to add binary to PATH on Ubuntu Linux Jan 13, 2022
@jsierles
Copy link
Member

I'm not able to reproduce this. Do you have . in your $PATH?

@lpil
Copy link
Author

lpil commented Jan 14, 2022

Do you have . in your $PATH?

Unfortunately not. Here it is

$ echo $PATH
/home/codespace/.rbenv/shims:/vscode/bin/linux-x64/899d46d82c4c95423fb7e10e68eba52050e30ba3/bin:/home/codespace/.nvm/current/bin:/home/codespace/.npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/codespace/.dotnet:/home/codespace/.dotnet/tools:/usr/local/sdkman/bin:/usr/local/sdkman/candidates/gradle/current/bin:/usr/local/sdkman/candidates/java/current/bin:/opt/maven/lts:/usr/local/cargo/bin:/usr/local/go/bin:/go/bin:/usr/local/py-utils/bin:/opt/conda/condabin:/home/codespace/.java/current/bin:/home/codespace/.nodejs/current/bin:/home/codespace/.php/current/bin:/home/codespace/.python/current/bin:/home/codespace/.ruby/current/bin:/home/codespace/.maven/current/bin:/home/codespace/.hugo/current/bin:/opt/oryx:/opt/nodejs/lts/bin:/opt/dotnet/lts:/opt/python/latest/bin:/opt/php/lts/bin:/opt/php-composer:/opt/yarn/stable/bin:/opt/hugo/lts::/opt/java/lts/bin:/opt/maven/lts/bin:/opt/ruby/lts/bin:/home/codespace/.local/bin:/usr/local/rvm/bin

Reproduction

Create a new codespace. I'm using this repo

image

Wait for it to boot.

Run cd to go to the home directory

Run curl -L https://fly.io/install.sh | sh

Run flyctl

@jsierles
Copy link
Member

jsierles commented Feb 8, 2022

So revisiting this - indeed you have to set your path manually the first time. This is true on all platforms - the install script will not modify your PATH.

For codespaces, you'll want to make sure that the flyctl install directory is added to your profile at boot time.

@jsierles jsierles closed this as completed Feb 8, 2022
@lpil
Copy link
Author

lpil commented Feb 8, 2022

Sorry @jsierles , I think there has been a misunderstanding here. I am not reporting that the path was unmodifed, rather that the install script was failing to print the information saying that it needs to be added to the PATH.

I have tested this again and the problem still exists with the latest version.

Here is the current output:

@lpil ➜ ~ $ curl -L https://fly.io/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1412    0  1412    0     0   6854      0 --:--:-- --:--:-- --:--:--  6854
######################################################################## 100.0%##O#- #                ######################################################################## 100.0%
set channel to shell
flyctl was installed successfully to /home/codespace/.fly/bin/flyctl
Run 'flyctl --help' to get started

The expected output should include the output of this part of the shell script:

	echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
	echo "  export FLYCTL_INSTALL=\"$flyctl_install\""
	echo "  export PATH=\"\$FLYCTL_INSTALL/bin:\$PATH\""
	echo "Run '$exe --help' to get started"

I think this should be reopened.

@lpil lpil changed the title flyctl install script fails to add binary to PATH on Ubuntu Linux flyctl install script mistakenly thinks that the binary is on the PATH on Ubuntu Linux when it is not Feb 8, 2022
@lpil lpil changed the title flyctl install script mistakenly thinks that the binary is on the PATH on Ubuntu Linux when it is not flyctl install script mistakenly thinks that the binary is on the PATH on Ubuntu Linux Feb 8, 2022
@jsierles
Copy link
Member

jsierles commented Feb 8, 2022

Ah OK. So I tried on a fresh ubuntu Docker container:

# curl -L https://fly.io/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1412    0  1412    0     0   3010      0 --:--:-- --:--:-- --:--:--  3010
######################################################################## 100.0%#=#=-#  #
set channel to shell
flyctl was installed successfully to /root/.fly/bin/flyctl
Manually add the directory to your $HOME/.bash_profile (or similar)
  export FLYCTL_INSTALL="/root/.fly"
  export PATH="$FLYCTL_INSTALL/bin:$PATH"
Run '/root/.fly/bin/flyctl --help' to get started

This means there must be something different in the environment you're testing. flyctl should not be in the PATH yet. I can try to test on codespaces when time permits.

@jsierles jsierles changed the title flyctl install script mistakenly thinks that the binary is on the PATH on Ubuntu Linux flyctl install script mistakenly thinks that the binary is on the PATH on Codespaces Ubuntu Feb 8, 2022
@jsierles jsierles reopened this Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants