Zsh & RVM woes (rvm-prompt doesn't resolve)

Wojtek Augustynski picture Wojtek Augustynski · Jul 9, 2011 · Viewed 16k times · Source

I recently saw the light and changed over to Zsh. I naturally used Oh My Zsh to configure it, as I'm noobish. So, there are several themes that have an rvm-prompt included and here is were my problems began. Everytime I load Zsh I have to rvm reload or else rvm-prompt is not resolved (zsh: command not found: rvm-prompt). Note that it resolves fine after I reload. Also, and in line, when I go to a directory that has its own .rvmrc (other gemset) and then I come out of it, the same problem occurs; I'm left with having to reload Zsh again. I have RVM in $PATH set. I have

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

in my .zshrc

I'm using the RVM plugin. Anybody know whats up? Not really a show stopper, just annoying.

Answer

jasongarber picture jasongarber · Feb 11, 2012

Make an alias to rvm-prompt. That's the most sure-fire answer. Arrange things in your .zshrc file in this order:

  1. alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt
  2. source $ZSH/oh-my-zsh.sh
  3. [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

If oh-my-zsh (OMZ) loads before RVM, which rvm-prompt fails silently, so you won't see RVM in your prompt (if supported by your theme) even though it is in your path later, after RVM loads.

If RVM loads before OMZ, you may get a zsh: command not found: rvm-prompt.

Aliasing your rvm-prompt to its actual location seems to solve the problem, regardless of which order RVM and OMZ are loaded in. I'd still recommend RVM at the bottom.

Putting the RVM load into .zshenv as suggested above would load RVM twice in iTerm 2 (and no, it was not still in my .zshrc) and would result in the prompt displaying "system" even though rvm-prompt and rvm current showed a specific ruby version and gemset.