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

Unable to use rvm on MacOS when using zsh #3967

Closed
ssbarnea opened this issue Mar 24, 2017 · 2 comments
Closed

Unable to use rvm on MacOS when using zsh #3967

ssbarnea opened this issue Mar 24, 2017 · 2 comments

Comments

@ssbarnea
Copy link

ssbarnea commented Mar 24, 2017

I switched to zsh few weeks ago but it seems that rvm is broken beyond repair, failing to activate itself.:

/usr/local/bin/zsh --version
zsh 5.3.1 (x86_64-apple-darwin16.3.0)
/bin/zsh --version
zsh 5.2 (x86_64-apple-darwin16.0)
set|grep -a SHELL
SHELL=/bin/zsh

Doing source "$HOME/.rvm/scripts/rvm from the command line works, no output but after this you get the rvm command available.

Still, if you try to do this from inside the .profile file, you may get some weird errors:

/Users/ssbarnea/.rvm/scripts/functions/selector_parse:145: parse error near `('
/Users/ssbarnea/.rvm/scripts/functions/selector:59: parse error near `('
/Users/ssbarnea/.rvm/scripts/cli:351: parse error

Here is the snipped from .profile:

[ -s "$HOME/.rvm/scripts/rvm" ] && {
  export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
  # shellcheck source=/dev/null
  source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
}

The funny part is that if I do source "$HOME/.rvm/scripts/rvm" from inside .zshrc file it work fine but when this done from inside the shared .profile file it fails.

For your information the last lines of the .zshrc aree:

source_sh () {
  emulate -LR sh
  . "$@"
}
source_sh $HOME/.profile

Which would translate into english as: now load the .profile file using bash compatibility mode.

While I do have a workaround, I raise this bug because I find the current behaviour buggy and confusing. Even the main documentation page referring to zsh and rvm doesn't even tell you how to enable rvm in zsh, by default it will not be loaded. See https://rvm.io/integration/zsh

@mpapis
Copy link
Member

mpapis commented Apr 8, 2017

RVM does not support sh shell - and it's what emulate sh does, it is not bash emulation - they are two different things. I wonder if it's possible to detect if the zsh is in the emulation mode for other shells - RVM will not work with then and we should issue an warning about it.

@mpapis
Copy link
Member

mpapis commented Sep 17, 2017

There is no way this can be fixed on RVM level... at least for RVM v1, it is not compatible with sh shell and you are running the sourcing of ~/.profile in the compatibility mode.

As nothing can be displayed while sourcing rvm we can not display a warning for it.

I wonder why it's required to do the emulate -LR sh for sourcing .profile? Any sh code will work in zsh. Could you just do source ~/.profile?

@mpapis mpapis closed this as completed Sep 17, 2017
@pkuczynski pkuczynski added this to the rvm-1.29.4 milestone Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants