Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"RVM is not a function" error

Tags:

ruby

rvm

RVM is installed on my machine (running Mac OSX 10.6.8), correctly and it runs fine. The odd thing is that to run it, I have to use source ~/.rvm/scripts/rvm for every new session. I tried making a symlink from it to /opt/local/bin/rvm, but when it runs it does nothing. I also tried creating a symlink from ~/.rvm/bin/rvm to /opt/local/bin/rvm, and when I run rvm in the Terminal it displays the help page, as expected. But when I try rvm use some_ruby_version it always displays "RVM is not a function, selecting rubies with 'rvm use ...' will not work.". How can I fix this?

My goal is to get it to the the point that I don't have to type the source command every session, and for some reason ~/.profile does not execute.

like image 410
Jwosty Avatar asked Mar 17 '12 18:03

Jwosty


People also ask

Is not a function selecting rubies with RVM use will not work?

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 an example.

What are the functions of RVM?

rvm can only be used for regression at the moment. the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a dot product between two vector arguments.

What is RVM in computer?

RVM stands for Ruby Version Manager. It is a command line tool which allows you to easily install, manage and work with different Ruby environments. With RVM, you can easily install different versions of Ruby and easily switch between them.


2 Answers

You have to source the RVM script into the current session because it makes changes to the shell environment - and it is absolutely impossible for that to be done from a child process. Your efforts at running RVM as an external command cannot succeed.

To actually fix this you have two choices:

  1. Configure your terminal emulator to start a login shell, rather than a non-login shell, so that your .profile is loaded.
  2. Modify .bashrc to source RVM instead, which works for non-login shells as well.

To do the second you can just add to ~/.bashrc:

if test -f ~/.rvm/scripts/rvm; then     [ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm fi 
like image 157
Daniel Pittman Avatar answered Sep 23 '22 20:09

Daniel Pittman


If you are using zsh as shell instead bash, you have to:

1.

vi ~/.zshrc  

2. Like Matt said, add:

if test -f ~/.rvm/scripts/rvm; then    [ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm fi 

3. Restart Terminall 4. Done!

rvm use 1.9.3 

Wil work

like image 32
Alberto Fortes Avatar answered Sep 25 '22 20:09

Alberto Fortes