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

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.

This question is related to ruby bash rvm

The answer is


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

     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.

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

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


Following work for me in ubuntu 19.1

source ~/.rvm/scripts/rvm

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


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.


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


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.

Thanks!


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.


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

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)


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

bash -l -c "rvm use 2.0.0"

Examples related to ruby

Uninitialized Constant MessagesController Embed ruby within URL : Middleman Blog Titlecase all entries into a form_for text field Ruby - ignore "exit" in code Empty brackets '[]' appearing when using .where find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException) How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite? How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? How to update Ruby with Homebrew?

Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to rvm

How to resolve "gpg: command not found" error during RVM installation? RVM is not a function, selecting rubies with 'rvm use ...' will not work SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/ Which Ruby version am I really running? rvm installation not working: "RVM is not a function" Installed Ruby 1.9.3 with RVM but command line doesn't show ruby -v rmagick gem install "Can't find Magick-config" How to Uninstall RVM? How to remove RVM (Ruby Version Manager) from my system