Scalingo / cli

Command Line client for Scalingo PaaS
https://cli.scalingo.com
Other
128 stars 24 forks source link

Installer should use a different default directory on macOS + arm64 (Apple Silicon) #611

Closed czj closed 1 year ago

czj commented 3 years ago

With an Intel processor based Mac, Homebrew is installed in /usr/local and this is also the default installation directory for the Scalingo CLI binary.

With an Apple processor (arch = arm64) Homebrew is installed in /opt/homebrew which makes Scalingo CLI install script crash.

However I can confirm that running the amd64 binary described in https://github.com/Scalingo/cli/issues/609 works perfectly (via Rosetta 2, automatically)

As uname -m returns arm64 - see https:/stackoverflow.comquestions65259300detect-apple-silicon-from-command-line about this - maybe you could integrate this, and change the default instillation directory accordingly ?

Currently the default directory it is hard-coded:

target_dir="${target_dir:-/usr/local/bin}""

https://github.com/Scalingo/cli/blob/9a45007ad95ce8b463da1f39947d6ac765973d55/dists/install.sh

Perhaps we could evolve to this pseudo code :

default_target_dir="/usr/local/bin"
box $arch in
  arm64)
    default_target_dir="/opt/homebrew/bin"
    ;;
esac

target_dir="${target_dir:-$default_target_dir}""

Otherwise you could detect if /opt/home/brew exists and use it for the default installation directory. If not you could fall back to the default /usr/local ?

czj commented 3 years ago

Sorry for the initial issue written in french ... I have talking too much in french to Scalingo on Twitter and support :)

curzolapierre commented 2 years ago

What is the state of this issue, @czj? If this still happening, could you confirm that the following command fix the issue?

curl -O https://cli-dl.scalingo.com/install && bash install -i "/opt/homebrew/bin"
czj commented 2 years ago

What is the state of this issue, @czj? If this still happening, could you confirm that the following command fix the issue?

@curzolapierre the command works, without any password entry. I had 1.23.0installed and it did not upgrade me to 1.24.0 so I had to run the curl -O https://cli-dl.scalingo.io/install && bash install (which asks for a password).

So the only minor issue is the default usage of /usr/local/bin/ which requires a password entry whereas /opt/homebrew/bin/ does not (and is homebrew's default on ARM64)

whereis scalingo
# scalingo: /opt/homebrew/bin/scalingo

which scalingo
# /usr/local/bin/scalingo

Semaphore CI, 1Password CLI, zed programming langage, Warp (terminal) also use /usr/local/bin/ and also require sudo / password entry.

czj commented 1 year ago

Thanks @SCKevinO !