rvm installation not working: "RVM is not a function"

RubyRvm

Ruby Problem Overview


I just installed RVM, but can't make it work. I have such line at the end of my .profile file:

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

I tried to run source .profile and restarting terminal, but still, when I run rvm use 1.9.2 I'm getting:

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

My system is Ubuntu 11.10.

Ruby Solutions


Solution 1 - Ruby

You need to run the following

$ source ~/.rvm/scripts/rvm

then run this

$ type rvm | head -n 1

and if you get

rvm is a function

the problem is solved.

You also need to run user$ rvm requirements to see dependency requirements for your operating system

Source: https://rvm.io/rvm/install/

I forget mention that you need to put this code into you ~/.bashrc or ~/.zshrc file and you will not need to write this code again. Cheers!

Solution 2 - Ruby

You are not using an login shell.

The process of enabling the login flag is described here, also some details on what a login shell is can be found here.

Thus, you need to check the option "Run as login shell" in the Gnome terminal's settings. It is required to open new terminal after this setting the flag.

Sometimes it is required to set the command to /bin/bash --login.


For remote connections it is important to understand the differene between running interactive ssh session and executing single commands.

While running ssh server and then working with the server interactively you are using login shell by default and it's all fine, but for ssh server "command" you are not using login shell and it would be required to run it with ssh server 'bash -lc "command"'.

Any remote invocation can have the same problem as executing single command with ssh.

Solution 3 - Ruby

To permanently resolve this just cut/paste following line:

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

From: ~/.bash_profile file

To: ~/.bashrc file

Reason this works is that .bashrc is executed each time you enter the terminal, and .bash_profile each time you login. That is why solution /bin/bash --login works, but you have to do that each time you enter the terminal. This way you are set until your next format, and you will forget all this by than :)

Solution 4 - Ruby

I too faced this problem. Finally i executed this line on terminal.

source ~/.rvm/scripts/rvm

Problem is fixed. Because this line will make the RVM instance a function for a particular time.

Solution 5 - Ruby

The latest RVM (rvm 1.11.6 (stable)) stopped working on Ubuntu (10.10 - 64 bit - nerdy gnat or whatever) - I kept getting

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

Before, I got the message, but 'rvm 1.9.3-p0@rails321' would work. Now, it wouldn't work - you couldn't change gemsets at all.

Nothing worked, until I found this - make this the LAST line in /home/your-name/.bashrc

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

Solution 6 - Ruby

As you said, the error shown could be the following one.

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.

As said above, just type '/bin/bash --login' in your terminal (after restarting your terminal), then type the comand 'rvm use 1.9.3' (for e.g.) and it will start using the same version.

Just execute the command 'ruby -v' to confirm that the RVM is using the updated version of Ruby.

Solution 7 - Ruby

I had this problem too on a fresh rvm installation, and non of the answers here fixed it. Going into the official rvm site, on the basics section, they have this command:

> # from http://rvm.io/rvm/basics

> source $(rvm 1.9.3 do rvm env --path)

You should change 1.9.3 for the ruby version that you actually want, and it'll make rvm a function regardless of the shell type.

Solution 8 - Ruby

even though you accepted an answer, i'd like to suggest another way .. ~/.bashrc is loaded before any shell is opened. Add that line at the end of that, and you don't need any of that login shell thing

Solution 9 - Ruby

Maybe you can try belows:

  • Your Terminal ->
  • Edit ->
  • Profile Preferences ->
  • Title and Command ->
  • Check the "Run command as a login shell"
  • Done

Solution 10 - Ruby

Run bash --login and then run rvm use 2.0.0.

Solution 11 - Ruby

Open Up the Terminal and then Go to Edit > Profile Preferences and then go to the Tab "Title and Command" and Check "Run Command as Login Shell".

Boot Up a Bash and Now you can install Gems directly from the terminal without the use of sudo and the error "RVM is not a function, selecting rubies with 'rvm use ...' will not work." will be eliminated.

Cheers.

Solution 12 - Ruby

All the above answers are valid. But when i faced the same issue, the solution was the following:

  • Update ZSH. (Tried to update directly din't work for some reason. So uninstalled and reinstalled updated version from here)

  • Set default shell as zsh (i.e. if you prefer zsh) using sudo chsh -s $(which zsh) $USER

  • Ensure that the following code is at the bottom of your .zshrc after you have installed the latest RVM probably using CURL from official RVM site

     [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
     source ~/.profile
    
  • MOST IMPORTANT POINT: Ensure that in your .zshrc file every export to PATH is appended with :$PATH. Which i believe was the root of my problems even after following the above steps.

  • post this all my problems of RVM Not being a function went away. If it still does not work, give some error trace over here. After a few hours of struggle to solve this issue, i'm sure i must have seen all related errors.

Hope it helps. Cheers!

Solution 13 - Ruby

Procedure for installing Ruby 1.9.3-p125 on Mac OSX 10.8 Mountain Lion

  1. You've already installed the latest XCode (>= 4.3) and and the command line Objective-C compiler "clang".
  2. You must run the "bash" shell for this procedure to work.
  3. Go to System Preferences
  4. Click on "Users & Groups"
  5. Click the lock on the bottom left of the panel and enter your password to unlock it.
  6. "Ctrl-Click" on your user icon in the left pane of the panel and choose "Advanced Options..."
  7. Change the Login Shell to "/bin/bash"
  8. Close the preferences
  9. Open a terminal window (press command+spacebar and type in "terminal")
  10. Follow the instructions at:

http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/

Notes:

  • To install ruby, you may need to specify the clang compiler:

    $ rvm install 1.9.3p125 --with-gcc=clang

  • If RVM gripes about /usr/local/rvm not found, you need to create a link:

    $ ln -s /Users/[your user name]/.rvm /usr/local/rvm

Solution 14 - Ruby

source ~/.bash_profile

... should do the trick ..., probably need to logout and login again.

https://stackoverflow.com/questions/4608187/how-to-reload-bash-profile-from-the-command-line

Solution 15 - Ruby

I'd got the same error because I'd ever installed the old rvm version ruby-rvm with the apt-get command.

I solved the problem by remove the script line to config the old rvm in .bashrc file.

Check the old rvm config script and then run source .profile

Solution 16 - Ruby

« Official » instructions are there: https://rvm.io/integration/gnome-terminal/

Solution 17 - Ruby

I fixed it by adding this line to .bash_profile:

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

Solution 18 - Ruby

I had the same error, but none of the solutions on this page seemed to work. For me it was enough to add the rvm executable to my path:

PATH=$PATH:/usr/local/rvm/bin/

Et voila!

Solution 19 - Ruby

I had the same issue and I did this in my .bash_profile and it worked. source "$HOME/.rvm/scripts/rvm".

Solution 20 - Ruby

For those who comes with same issue and they are using lubuntu like me I followed this link :

You start your terminal with

> lxterminal -e "bash -il"

Thank to @mpapsis who pointed me to the right direction

Solution 21 - Ruby

My unclean way to change of ruby version is

rvm alias create default ruby-2.2.3 && source ~/.bashrc && rvm list

it works because I have the line bellow in my ~/.bashrc but strangely it don't do the job automatically.

[[ -s "/usr/local/rvm/bin/rvm" ]] && source "/usr/local/rvm/bin/rvm"

I tried to connect with --login to my docker container

docker run -it imagename `/bin/bash --login`

but in this case the container stay open in background and I can't enter commands.

I tried both zhc and terminal with the option "open with /bin/bash --login"

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
QuestionamorfisView Question on Stackoverflow
Solution 1 - RubyJorge GarcíaView Answer on Stackoverflow
Solution 2 - RubympapisView Answer on Stackoverflow
Solution 3 - RubyHaris KrajinaView Answer on Stackoverflow
Solution 4 - RubyBastin RobinView Answer on Stackoverflow
Solution 5 - RubyRod McLaughlinView Answer on Stackoverflow
Solution 6 - RubyRajesh OmanakuttanView Answer on Stackoverflow
Solution 7 - RubyvcanalesView Answer on Stackoverflow
Solution 8 - Rubykapv89View Answer on Stackoverflow
Solution 9 - RubyFeudaView Answer on Stackoverflow
Solution 10 - RubyGowri TummaView Answer on Stackoverflow
Solution 11 - RubyajknzholView Answer on Stackoverflow
Solution 12 - RubyVishnu NarangView Answer on Stackoverflow
Solution 13 - RubyGeorge CampbellView Answer on Stackoverflow
Solution 14 - Rubyuser1800885View Answer on Stackoverflow
Solution 15 - RubyryancheungView Answer on Stackoverflow
Solution 16 - RubySidhannoweView Answer on Stackoverflow
Solution 17 - RubyAlekseiPetrovskiView Answer on Stackoverflow
Solution 18 - RubyRafael BugajewskiView Answer on Stackoverflow
Solution 19 - RubySadiksha GautamView Answer on Stackoverflow
Solution 20 - RubynizzinView Answer on Stackoverflow
Solution 21 - RubybormatView Answer on Stackoverflow