moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
9.88k stars 520 forks source link

gvm-installer.sh does not work after macOS Catalina #397

Open bryonbaker opened 2 years ago

bryonbaker commented 2 years ago

Catalina moved from BASH to zsh. The section of code to update .zshrc is detecting the shell from the #! in the script and thus not updating .zshrc.

The code at line 100 should update the profile based on the login shell, not the shell that is running the script. The following code fixes the problem:

if [ -z "$GVM_NO_UPDATE_PROFILE" ] ; then
  if [ -n "$ZSH_NAME" ]; then
    update_profile "$HOME/.zshrc"
  elif [ "$(uname)" == "Linux" ]; then
    update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
  elif [ "$(uname)" == "Darwin" ]; then
    LOGIN_SHELL=$(finger $(id -F) | grep Shell | cut -d : -f 3)
    echo "macOS detected. User shell is:" $LOGIN_SHELL
    if [ $LOGIN_SHELL == "/bin/zsh" ]; then         # macOS moved to ZSH after macOS Catalina
      update_profile "$HOME/.zshrc"
    else
      update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
    fi
  fi
fi
soulteary commented 2 years ago

Maybe this will help you: https://github.com/moovweb/gvm/issues/406

ankitcharolia commented 11 months ago

@bryonbaker kindly try this GO Version Manager: https://github.com/ankitcharolia/goenv