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

RubyBashRvm

Ruby Problem Overview


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.

Ruby Solutions


Solution 1 - Ruby

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

Solution 2 - Ruby

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

Solution 3 - Ruby

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

Solution 4 - Ruby

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"

  1. Restart terminal and try RVM command again

Solution 5 - Ruby

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

Solution 6 - Ruby

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.

Solution 7 - Ruby

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

bash -l -c "rvm use 2.0.0"

Solution 8 - Ruby

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.

Solution 9 - Ruby

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.

Solution 10 - Ruby

Following work for me in ubuntu 19.1

source ~/.rvm/scripts/rvm

Solution 11 - Ruby

I think this more generic solution

echo 'source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

Solution 12 - Ruby

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

Solution 13 - Ruby

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

Solution 14 - Ruby

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)

Solution 15 - Ruby

     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.

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
Questionuser3678471View Question on Stackoverflow
Solution 1 - RubyBroiSatseView Answer on Stackoverflow
Solution 2 - RubyinquisitiveView Answer on Stackoverflow
Solution 3 - RubyakbarbinView Answer on Stackoverflow
Solution 4 - RubyJohn VargheseView Answer on Stackoverflow
Solution 5 - RubyhhzhuView Answer on Stackoverflow
Solution 6 - RubySumit MunotView Answer on Stackoverflow
Solution 7 - RubyVigintas LabakojisView Answer on Stackoverflow
Solution 8 - RubySiva PraveenView Answer on Stackoverflow
Solution 9 - RubyArjunView Answer on Stackoverflow
Solution 10 - RubySagar JethiView Answer on Stackoverflow
Solution 11 - RubyKapil BhosaleView Answer on Stackoverflow
Solution 12 - RubyWiredInView Answer on Stackoverflow
Solution 13 - RubyMike MilkmanView Answer on Stackoverflow
Solution 14 - Rubyuser8099101View Answer on Stackoverflow
Solution 15 - RubyKiruthika kanagarajanView Answer on Stackoverflow