How do I change my Ruby version using RVM?

RubyRvm

Ruby Problem Overview


I am not able to switch the current Ruby version:

➜  ~  rvm list

rvm rubies

   ruby-1.9.2-p290 [ x86_64 ]
   ruby-1.9.3-p0 [ x86_64 ]

➜  ~  rvm use ruby-1.9.3-p0

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

Ruby Solutions


Solution 1 - Ruby

Fixed it. I needed to add:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM 

to .zshrc

Solution 2 - Ruby

This happened to me too. I had:

export PATH=~/.rvm/bin:$PATH

Added in my .bashrc.

All I had to do was add another

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

to the same file and it worked! Of course, you have to restart your terminal after that.

Solution 3 - Ruby

Your shell doesn't know about the RVM function. After you install it, it tells you how to take care of this. Or go to the install page on the RVM site and check out the section titled "2. Load RVM into your shell sessions as a function"

Run this once to add the line that loads rvm into your ~/.bash_profile:

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

or manually add it yourself. (Note that on some systems, you will want to put it in other places, for example on my system, Mac OSX Lion, I put it in ~/.profile)

Solution 4 - Ruby

(Kubuntu 11.10) The ~/.bash_profile is now called ~/.profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.profile
source ~/.profile
rvm info # And now the fields display

Solution 5 - Ruby

To Change the Default Version of ruby:

In Ubuntu 11.10

please change your GNOME terminal setting :

Go to Terminal and then follow the following instructions:

1.  Edit > Profile Preferences
2.  Open Title and Command Tab               
3.  Check Run Command as a login Shell 
4.  Restart terminal

Run this command on terminal:

rvm --default use ruby_Version

Solution 6 - Ruby

To add all RVM functionality to your .bash_profile you should use following command:

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

After that you should reload the current shell or open a new terminal session and type the following command to reload .bash_profile:

source .bash_profile

Solution 7 - Ruby

The above solution will only work, if RVM is installed for the current user. A more general solution would use the RVM path variable:

# The following code loads RVM as user or system install:
[[ -s "$rvm_path/scripts/rvm" ]] && . "$rvm_path/scripts/rvm"

Solution 8 - Ruby

I just had to invoke source ~/.bash_profile

Solution 9 - Ruby

On a clean install of Ubuntu 12.04 I ran into the same issue. The RVM installer creates or appends to a file called ~/.bash_login the necessary bit of code to avoid the original problem:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

However this does not seem to get invoked. Adding it to ~/.bashrc resolved the issue for me.

Solution 10 - Ruby

Installing RVM, See here http://octopress.org/docs/setup/rvm/

Solution 11 - Ruby

In my case on Ubuntu, the entry in ~/.bashrc had:

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

instead of:

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

Notice the missing space between . and "$HOME.

Also, if this is the problem, you should also be noticing an error on top when you start your terminal.

Solution 12 - Ruby

I had a global install of RVM, which runs /etc/profile.d/rvm.sh. However, that script requires the BASH_VERSION or ZSH_VERSION to be set. I was running from crontab, which uses "sh".

I created a wrapper script that uses /bin/bash to source /etc/profile.d/rvm.sh.

Solution 13 - Ruby

> You need to change your terminal emulator preferences to allow login > shell. Sometimes it is required to use /bin/bash --login as the > command.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondonaldView Question on Stackoverflow
Solution 1 - RubydonaldView Answer on Stackoverflow
Solution 2 - RubyThe Mitra BoyView Answer on Stackoverflow
Solution 3 - RubyJoshua CheekView Answer on Stackoverflow
Solution 4 - RubyLindsayView Answer on Stackoverflow
Solution 5 - RubyMayank RaipureView Answer on Stackoverflow
Solution 6 - RubyНедоброе ПривидениеView Answer on Stackoverflow
Solution 7 - Rubyuser2408574View Answer on Stackoverflow
Solution 8 - RubyBehzadView Answer on Stackoverflow
Solution 9 - RubygordonbandersonView Answer on Stackoverflow
Solution 10 - RubyhahakubileView Answer on Stackoverflow
Solution 11 - Rubymohitj2007View Answer on Stackoverflow
Solution 12 - RubydfrankowView Answer on Stackoverflow
Solution 13 - RubyMoamen AbdelwahedView Answer on Stackoverflow