194

List the ruby versions

console:~$ rvm list

rvm rubies

ruby-2.0.0-p481 [ i686 ]

# => - current
# =* - current && default
#  * - default

Try to use a specific version of ruby

console:~$ rvm use 2.0.0

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.
Arslan Ali
  • 16,978
  • 8
  • 56
  • 70
user3678471
  • 2,163
  • 2
  • 15
  • 17

15 Answers15

275

Your console is not running as a login shell and hence have no access to rvm function. If you are running Ubuntu, you can:

  1. Open console
  2. Select Edit -> Profile Preferences
  3. Select tab: Title and Command
  4. Check box 'Run command as a login shell'
  5. Restart terminal
BroiSatse
  • 42,553
  • 8
  • 56
  • 84
141

Type bash --login from your terminal. And then give rvm use 2.0.0

Martin Tournoij
  • 24,971
  • 24
  • 101
  • 136
inquisitive
  • 3,558
  • 6
  • 26
  • 54
  • @AdityaPednekar So, sometimes reading the error/console message actually helps, `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.` specifies the details. – inquisitive Jul 10 '18 at 10:02
  • 2
    Yeah, It helps realize how unreasonably complex it is to use `rvm` compared to `nvm` – Jannis Ioannou Apr 30 '20 at 16:09
  • 1
    Thanks this worked for me and it saved lot of time. – Jagadeeswar Mar 25 '21 at 08:26
82

It seems like your rvm does not load ".bash_profile" properly. I have done to fix it in MAC OS X or Ubuntu 14.04 by opening terminal and write:

source ~/.rvm/scripts/rvm
akbarbin
  • 4,824
  • 1
  • 26
  • 31
54

My env is OSX Yosemite. Had the same issue .... solved by adding the following

1) edit and add the following line to .bash_profile file.

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

2) Restart terminal and try RVM command again

Esmaeil MIRZAEE
  • 944
  • 10
  • 13
John Varghese
  • 541
  • 4
  • 2
44

If you don't want that every time you open a terminal, do the suggestion above again, just add

source ~/.rvm/scripts/rvm

at the end of ~/.bashrc

René Vogt
  • 41,709
  • 14
  • 73
  • 93
hhzhu
  • 559
  • 4
  • 6
19

The error is due to rvm is not running as in login shell. Hence try the below command:

/bin/bash --login

You will able run rvm commands instantly as login shell in terminal.

halfer
  • 19,471
  • 17
  • 87
  • 173
Sumit Munot
  • 3,594
  • 1
  • 28
  • 51
15

Same principle as other answers, just thought it was quicker than re-opening terminals :)

bash -l -c "rvm use 2.0.0"
Vigintas Labakojis
  • 1,001
  • 15
  • 20
  • Someone should come up with a better answer than all of these. This is the only item in all the answers to this question that works for me but this is not something I want to do all the time. Im on Mac OSX Sierra – djangofan Jun 22 '17 at 01:06
10

You need to add source ~/.rvm/scripts/rvm to ~/.your_shellrc file. From now when you load a shell, rvm will be loaded.

For example:

if you are using zsh shell, need to add in ~/.zshrc file

if you are using bash shell, need to add in ~/.bashrc file

And then open a new tab to see the effect.

Siva Praveen
  • 1,757
  • 15
  • 20
8

For me in Ubuntu(18.08), I have added below line in .bashrc and it works.

 source /home/username/.rvm/scripts/rvm

Please add this line.

Arjun
  • 785
  • 1
  • 7
  • 18
6

Following work for me in ubuntu 19.1

source ~/.rvm/scripts/rvm
Sagar Jethi
  • 1,735
  • 18
  • 19
6

I think this more generic solution

echo 'source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
Kapil Bhosale
  • 93
  • 2
  • 7
3

From a new Ubuntu 16.04 Installation

1) Terminal => Edit => Profile Preferences

2) Command Tab => Check Run command as a login shell

3) Close, and reopen terminal

rvm --default use 2.2.4
WiredIn
  • 3,941
  • 4
  • 26
  • 22
1

If RVM was installed with dedicated ubuntu RVM installer https://github.com/rvm/ubuntu_rvm the path to RVM scripts will be different /usr/share/rvm/scripts/rvm. So to add it to your .bashrc run the following command:

echo 'source "/usr/share/rvm/scripts/rvm"' >> ~/.bashrc
Mike Milkman
  • 555
  • 7
  • 14
0

FWIW- I just ran across this as well, it was in the context of a cancelled selenium run. Perhaps there was a sub-shell being instantiated and left in place. Closing that terminal window and opening a new one was all I needed to do. (macOS Sierra)

0
     Usually this is caused by shell initialization files. Search for PATH=... entries.
     You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
     To fix it temporarily in this shell session run: rvm use ruby-2.6.5
     To ignore this error add "rvm_silence_path_mismatch_check_flag=1" to your "~/.rvmrc" file.