Bratish Goswami

Personal website and blog

RVM is Not Working in ZSH

Just switched from bash to zsh and suddenly RVM stopped working. Kept getting command not found errors. Really frustrating when you're trying to work with different Ruby versions.

$ rvm use 1.9.2
zsh: command not found: rvm

The Solution:

RVM installation script probably added the RVM sourcing to your ~/.bashrc or ~/.bash_profile, but zsh uses ~/.zshrc.

You need to add this line to your ~/.zshrc:

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

Or if you installed RVM system-wide:

[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"

Alternative approach:

If you want to be more explicit, you can also add this to your ~/.zshrc:

export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

After adding this, either restart your terminal or run:

source ~/.zshrc

Now RVM should work perfectly with zsh. You can verify with:

rvm list
rvm use 1.9.2
ruby -v