Question

I'll start by saying I'm not an expert at command-line, so I really only barely know what I'm doing.

I cannot get RVM and oh-my-zsh to play nice together. I've tried several different solutions posted around, some on SO, but nothing I have found seems to fix the issue.

Initially, someone else setup RVM on my machine. I later setup oh-my-zsh myself, and remember having a lot of trouble doing so.

My .zhsrc file is completely default except for these 2 lines

export PATH=$HOME/bin:/usr/local/bin:/usr/local/rvm/bin:$PATH

#pretty sure this line does nothing, although I've seen this fix around
# several places. I noticed that I don't seem to have an .rvm file in my 
# home directory which would be an issue, but I have no idea how to 
# go about correcting this.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" 

I added the /usr/local/rvm to the Path directive as zsh returns zsh: rvm command not found without it there. Otherwise most rvm command work, with the exception of rvm use which throws the following error:

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 a example.

I have ensured the profile preferences on my profile in iTerm2 are set to "Login Shell" as recommended by RVM

iTerm2 Preferences - Login Shell

I have tried changing these preferences to the "Command" option and using the recommended /bin/bash/ --login as the command, however zsh no longer appears to work when this happens. Changing the command to /bin/zsh/ --login allows zsh to work again but does not solve the problem as I still get the "RVM is not a function" error when trying to run rvm use

The default ruby in RVM is set to 2.0.0. I can run ruby -v in my home folder and get the ruby version output which shows the default version.

Working on rails projects, I can run all rails commands IF the Gemfile specifies ruby 2.0.0, the default. However on a project that uses a different version, I get the following error:

Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3

Then I cannot run rvm use 1.9.3 as it returns the above mentioned error.

How can I make zsh play nice with RVM?

Some info about my setup:

  • Mac OSX 10.9.1 (Mavericks)
  • iTerm2
  • Zsh 5.0.2 with oh-my-zsh
  • RVM 1.5.1
Was it helpful?

Solution 2

Turns out that RVM was installed in the wrong place. When I had initially installed RVM I believe I did so with the sudo command, which ran the multi-user install (installed to /usr/local/rvm), and not the single user (should be in ~/.rvm/scrips/rvm), which is why all the posted solutions were not working for me.

I had to uninstall RVM with rvm implode. There were some permissions issues, so I had to manually go in and delete the files that could not be deleted. Ran the curl command to re-install RVM and now it's installed in the correct place.

Sourcing RVM in my .zshrc with [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" now works properly and I can switch between rubies.

OTHER TIPS

For me, I just had to add

source $HOME/.rvm/scripts/rvm

to my ~/.zshrc and it started working, after having the same error message as in this SO question.

@trustkr's answer worked for me, but would like to add...

I ran into this issue immediately after install of rvm. In order for the

source

to work in in the ~/.zshrc file to work, you will need either start a new terminal session and work there OR you can run

source ~/.rvm/scripts/rvm

in the same terminal session in which you installed.

[Mac OS 10.10.5 - iTerm - zsh]

I had the same issue added this one line at end of .zshrc file

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

and works now everything works fine on my ubuntu 16.04 operating system :)

You need to run the following:

$ source ~/.rvm/scripts/rvm

then run this

$ type rvm | head -n 1

and the result will be like

rvm is a shell function from /home/sun/.rvm/scripts/cli

Hope that helps!

Another solution :

1) In the terminal run :

which rvm

The output in my case is ---> /usr/share/rvm

2) Open .zshrc file

nano ~/.zshrc

add "source + the_path_to_your_rvm + /scripts/rvm", in my case it's :

source /usr/share/rvm/scripts/rvm

3) save the file (.zshrc)

4) close the terminal and open it again

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top