Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM is not working in ZSH

Tags:

macos

ruby

zsh

rvm

I'd like to try out the ZSH shell on my Mac, but I also do a lot of Ruby and Rails development, so I use RVM quite a bit too. The problem is that I can't seem to get RVM to work in ZSH, and it's working fine in the default Bash shell:

> zsh
> rvm 1.9.2
> ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
> which ruby
/usr/bin/ruby

I can definitely confirm that RVM is installed, as well as ruby 1.9.2 under RVM; I use it all the time in Bash. Running an rvm list in ZSH shows this, interestingly:

rvm rubies

   ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

This is happening on both my iMac and MacBook Pro. I am using OS X 10.6.6 on both, ZSH 4.3.9 on the iMac (4.3.10 on the laptop). Nothing fancy like oh-my-zsh just yet.

I tried looking at the documentation on RVM's website, but nothing helped me there.

like image 886
swilliams Avatar asked Jan 21 '11 04:01

swilliams


People also ask

Is not a function selecting rubies with RVM use will not work?

RVM is not a function, selecting rubies with 'rvm use ...' will not work. You need to change your terminal emulator preferences to allow login shell. Sometimes it is required to use `/bin/bash --login` as the command. Please visit https://rvm.io/integration/gnome-terminal/ for an example.

Can you use RVM on Windows?

RVM supports most UNIX like systems and Windows (with Cygwin or Bash on Ubuntu on Windows). The basic requirements are bash , curl , gpg2 and overall GNU version of tools - but RVM tries to autodetect it and install anything that is needed.

What does RVM install do?

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.


6 Answers

Do you have this line in your ~/.zshrc?

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
like image 81
intellidiot Avatar answered Oct 04 '22 14:10

intellidiot


Note March 2014:

With latest RVM, the following line:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 

isn't needed anymore, and it shouldn't be in your ~/.zshrc.

Documentation has been updated in RVM documentation with Zsh:

Make sure in iTerm2 Preferences: Login shell option is set (do not use Command option). This is required for RVM to work.

If you are still getting rvm is not a function errors on iTerm, try:

rvm get stable --auto-dotfiles
like image 30
raviolicode Avatar answered Oct 04 '22 13:10

raviolicode


Note November 2014

The rvm installation instructions warn that .zshrc doesn't include $PATH when setting PATH, thus replacing PATH's contents without regard for what already exists in PATH.

To remedy this I now append PATH to have .rvm/bin and then prepend $PATH at the beginning of setting PATH on the second line:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

export PATH=$PATH:"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/mysql/bin:/opt/local/bin"
like image 23
aaronbartell Avatar answered Oct 04 '22 15:10

aaronbartell


I had the same problem, I solved using this after "ruby on rails" installation:

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc

and

source ~/.zshrc
like image 27
3 revs, 2 users 80% Avatar answered Oct 04 '22 15:10

3 revs, 2 users 80%


I use zsh, and had [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" in my .zshrc file, but was getting a parse error:404.

When I moved that line to the .profile file, the error stopped. It seems it was conflicting with something in my .zshrc file, and perhaps running it in .profile avoided the .zshrc file incompatibility. I haven't been able

like image 32
Tim Avatar answered Oct 04 '22 15:10

Tim


I got it working on Manjaro Linux (zsh) by adding source /usr/share/rvm/scripts/rvm to $HOME/.zshrc

like image 34
Alexanderius Avatar answered Oct 04 '22 13:10

Alexanderius