117

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.
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
donald
  • 23,587
  • 42
  • 142
  • 223
  • are you sure you installed rvm correctly ? what OS are you using ? – lesce Dec 29 '11 at 04:33
  • 2
    Append the output of `rvm info` to your question please. – the Tin Man Dec 29 '11 at 04:34
  • I had a similar problem by installing rvm with apt-get on Ubuntu 11.10, I had to remove it and reinstall it with `$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) ` – lesce Dec 29 '11 at 04:41
  • 4
    Do you have the RVM load function in your shell's startup script? `[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"` is the code to use. If you have RVM installed in your path, but you don't have that in your startup script, you can get the `RVM is not a function` error. – Michelle Tilley Dec 29 '11 at 04:43
  • This solution works for me - https://rvm.io/integration/gnome-terminal/ – gotqn Mar 26 '13 at 20:31

13 Answers13

124

Fixed it. I needed to add:

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

to .zshrc

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
donald
  • 23,587
  • 42
  • 142
  • 223
58

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.

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
The Mitra Boy
  • 764
  • 1
  • 6
  • 13
  • 1
    i had this same line (the [[ -s "$HOME/...) in my ~/.bash_profile and that didn't seem to "take" when i opened a new terminal...but when i added the line below the PATH line in the ~/.bashrc, it did work -- meaning, i could type rvm use 1.9.3 and it would immediately recognize rvm as a command without me needing to first type source ~/.bash_profile -- i'm not a linux person, so this confuses me, but i'm glad this got it working. perhaps someone can clarify my confusion. – TimDog Feb 19 '12 at 16:53
  • that's great, i just put this line in ~/.bashrc, it works. but i also don't know why. – Keating Mar 21 '12 at 06:28
  • Yeah its working. But every time I restart my machine I have to give above mentioned commands. If I do not provide the commands it says rvm is not a function. – Apurva Mayank Mar 22 '12 at 05:42
11

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)

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Joshua Cheek
  • 30,436
  • 16
  • 74
  • 83
9

(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
docwhat
  • 11,435
  • 6
  • 55
  • 54
Lindsay
  • 91
  • 1
  • 1
6

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
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Mayank Raipure
  • 1,773
  • 15
  • 12
5

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
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
4

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"
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
3

I just had to invoke source ~/.bash_profile

EdChum
  • 376,765
  • 198
  • 813
  • 562
Behzad
  • 91
  • 1
  • 3
3

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.

Tisho
  • 8,320
  • 6
  • 44
  • 52
gordonbanderson
  • 221
  • 2
  • 5
1

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

hahakubile
  • 6,978
  • 4
  • 28
  • 18
  • Don't use non-authoratative sources for installing RVM. The [RVM installation page](http://rvm.io/rvm/install) specifically says: "Note that that any outside tutorials are NOT supported whether they work or not. Tutorials are great, however we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods." – the Tin Man Sep 15 '14 at 20:01
1

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.

mohitj2007
  • 91
  • 5
0

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

0

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.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
dfrankow
  • 20,191
  • 41
  • 152
  • 214