Wojtek Augustynski
Wojtek Augustynski

Reputation: 161

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

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.

Upvotes: 16

Views: 17733

Answers (6)

Gilles Essoki
Gilles Essoki

Reputation: 557

The simplest way to get rid of it is to install RVM (Ruby Virtual Manager). You would then actually appreciate the theme.

curl -sSL https://get.rvm.io | bash

The problem resolves itself after that..

Upvotes: 7

lotosbin
lotosbin

Reputation: 689

Add the following to ~/.zshrc in

alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt

Save

source ~/.zshrc

Reference: http://xufei.logdown.com/posts/2012/09/09/zsh-rake-rvm-prompt

Upvotes: -1

jasongarber
jasongarber

Reputation: 2206

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.

Upvotes: 21

John
John

Reputation: 3296

I had the same problem until I put [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" into a .zshenv file instead of the .zshrc file.

Upvotes: 19

mik
mik

Reputation: 75

This problem is actually adressed in rvm's zsh-FAQ.

http://beginrescueend.com/integration/zsh/

adding __rvm_project_rvmrc to your .zshrc solves the issue.

I am adding this as an answer because I just found this while googling the issue and the above solution just sets the ruby version to rvm's default and does not work with gemsets.

Upvotes: 1

bowsersenior
bowsersenior

Reputation: 12574

Not sure this will solve your problems, but it's worth a try anyways.

After a recent update to rvm, I had similar problems with oh-my-zsh. I uninstalled both rvm and oh-my-zsh then re-installed (install oh-my-zsh first, since it will copy a bunch or rvm paths into your ~/.zshrc if you install rvm first).

Things worked a little better, except rvm-prompt wouldn't work right with a new terminal window. I wound up sticking the following at the end of my ~/.zshrc and things work fine now:

rvm use default

I think some there is some kind of chicken-and-egg problem with the load order of rvm and oh-my-zsh with recent versions of rvm. Not sure which is to blame, but I hope it gets resolved by one or both of them!

Upvotes: 4

Related Questions