46

I installed RVM using the single instruction mentioned at the RVM website (using git).

Then I installed Ruby version 1.9.2 and 1.8.7 using:

rvm install 1.9.2
rvm install 1.8.7

However, I cannot find the Ruby binary. When I try to execute the command, I get the following error:

[root@server1 support]# rvm use 1.9.2
Using /usr/local/rvm/gems/ruby-1.9.2-p136

[root@server1 support]# ruby
-bash: ruby: command not found

Here is the output of rvm info:

[root@server1 support]# rvm info

system:

  system:
    uname:       "Linux server1.myserver.com 2.6.18-194.26.1.el5.028stab070.14 #1 SMP Thu Nov 18 16:34:01 MSK 2010 x86_64 x86_64 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.2.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]"

  homes:
    gem:          "not set"
    ruby:         "not set"

  binaries:
    ruby:         ""
    irb:          ""
    gem:          ""
    rake:         ""

  environment:
    PATH:         "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/rvm/bin"
    GEM_HOME:     ""
    GEM_PATH:     ""
    MY_RUBY_HOME: ""
    IRBRC:        ""
    RUBYOPT:      ""
    gemset:       ""


[root@server1 support]#
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
YD8877
  • 10,401
  • 20
  • 64
  • 92
  • Please type `rvm info` at the command-line, and add its output to your question by editing it. – the Tin Man Feb 06 '11 at 04:25
  • 1
    Was your intention to do a system-wide installation of RVM as root, or a single-user installation? If it was a single user installation, you should NOT be running as root. – the Tin Man Feb 06 '11 at 07:39

10 Answers10

75

RVM requires a minor addition to your ~/.bashrc or ~/.bash_profile to initialize it when you log-in. It is specified in the installation docs in the Post Install section. Did you do that?


Per your rvm info output, it looks like you haven't completed your installation. All the entries in the output should have corresponding values. So, I suspect you haven't added:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

to your ~/.bashrc or ~/.bash_profile and then started a new session.

If you are doing a "Multi-User" installation then you'll need to do a lot more. Have you modified /etc/profile, or, if you are using Bash as your shell, have you modified /etc/bash.bashrc to include:

# Load RVM if it is installed,
#  first try to load  user install
#  then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
  . "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
  . "/usr/local/rvm/scripts/rvm"
fi

and started a new shell?

Personally I don't like the multi-user install as much as the single-user install, and don't recommend it but your mileage might vary.


As a FYI: In a discussion with the RVM maintainers on IRC last year, they told me they do not recommend the system-wide installation, and instead recommend the local "single-user" installation, even for servers.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • So, how do i uninstall the RVM which i've already installed ? So i can do a user installation ? – YD8877 Feb 07 '11 at 17:36
  • Just delete the directory and remove the associated line from your `~/.bashrc` or `~/.bash_profile` and restart your terminal session. It's all covered nicely in the RVM docs. Try `rvm help` and read about `implode`. – the Tin Man Apr 07 '11 at 14:58
  • The contents of my ~/.bash_profile is exactly the line you've said should be added. Still every time I open a shell, the rvm info returns the same output as in the question and the ruby command doesn't work. I did a single-user install. What else could be wrong? – Slavo Sep 06 '11 at 19:25
  • 2
    You can use also `source $HOME/.rvm/scripts/rvm` – mikatakana Jan 01 '14 at 12:01
  • Dead links. Fix please. – Tim Nov 14 '14 at 17:31
  • 1
    You know that you don't have to ask someone else to fix links, you can do that yourself by submitting an edit. That's the beauty of [so]. – the Tin Man Nov 14 '14 at 18:16
  • I was struggling with this for awhile. Ran the update to .bash_profile, no dice. Ran the update to .bashrc, and now I'm good to go. I'm running xfce. – Eric Fuller Mar 21 '16 at 03:55
16

I had similar problem (using Ubuntu 13.10) to solve it

$ source .rvm/scripts/rvm 

and for long term

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

$ ruby -v


The program 'ruby' can be found in the following packages:
 * ruby1.8
 * ruby1.9.1
Try: sudo apt-get install <selected package>

$ source .rvm/scripts/rvm

$ ruby -v

ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
Alter Lagos
  • 12,090
  • 1
  • 70
  • 92
Fredy
  • 169
  • 1
  • 2
15

I installed Ruby on Rails on a Ubuntu 11.10 VM, using "HOW TO INSTALL RUBY ON RAILS IN UBUNTU 11.10".

After installing it, I was running into the same issue. The only thing that seems to be missing from the tutorial in my opinion, is the following command:

rvm --default use 1.9.2

Although Ruby is properly installed, RVM seems to redefine in each session Ruby is to be used. The problem was that the default Ruby pointed to the "system ruby", and, in my case, this one pointed to nowhere and made the call rvm info return a result similar to the initial post.

To solve this issue, one of the follwings commands must be used:

rvm  --default use 1.9.x

or (valid only for the current session)

rvm use 1.9.x

Before I could start the server, I also came across "ExecJS and could not find a JavaScript runtime". As proposed in several answers, I solved it by adding the following lines to the Gemfile.

gem 'execjs'

gem 'therubyracer'

and running bundle install afterwards.

Community
  • 1
  • 1
Micael Queiroz
  • 171
  • 1
  • 4
8

I faced the same issue. You might need to login first:

/bin/bash --login
Bruno Paulino
  • 5,611
  • 1
  • 41
  • 40
5

Here is how to fix undetected Rubies inside RVM.

First, I did a sanity check to make sure that very thing looks great, then ran

rvm use ruby --default

which did the job. It comes down to this command:

-SVE1411EGXB:~/code$ cd app1/
  -SVE1411EGXB:~/code/app1$ rails s
The program 'rails' can be found in the following packages:
 * ruby-railties-3.2
 * ruby-railties-4.0
Try: sudo apt-get install <selected package>
  -SVE1411EGXB:~/code/app1$ rails s
The program 'rails' can be found in the following packages:
 * ruby-railties-3.2
 * ruby-railties-4.0
Try: sudo apt-get install <selected package>
  -SVE1411EGXB:~/code/app1$ which ruby
  -SVE1411EGXB:~/code/app1$ which gem
  -SVE1411EGXB:~/code/app1$ rvm list

rvm rubies

=* ruby-2.1.2 [ x86_64 ]

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

  -SVE1411EGXB:~/code/app1$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz

Upgrading the RVM installation in /home  /.rvm/
    RVM PATH line found in /home  /.profile /home  /.bashrc /home  /.zshrc.
    RVM sourcing line found in /home  /.bashrc /home  /.bash_profile /home  /.zlogin.
Upgrade of RVM in /home  /.rvm/ is complete.

# nullsoulexception,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: http://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:

  * No new notes to display.

  -SVE1411EGXB:~/code/app1$ rails s
The program 'rails' can be found in the following packages:
 * ruby-railties-3.2
 * ruby-railties-4.0
Try: sudo apt-get install <selected package>
  -SVE1411EGXB:~/code/app1$ source ~/.rvm/scripts/rvm
  -SVE1411EGXB:~/code/app1$ rvm requirements
Checking requirements for ubuntu.
Requirements installation successful.
  -SVE1411EGXB:~/code/app1$ rvm get stable
Downloading https://get.rvm.io
Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz

Upgrading the RVM installation in /home  /.rvm/
    RVM PATH line found in /home  /.profile /home  /.bashrc /home  /.zshrc.
    RVM sourcing line found in /home  /.bashrc /home  /.bash_profile /home  /.zlogin.
Upgrade of RVM in /home  /.rvm/ is complete.

# nullsoulexception,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: http://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:

  * No new notes to display.

RVM reloaded!
  -SVE1411EGXB:~/code/app1$ rvm reload
RVM reloaded!
  -SVE1411EGXB:~/code/app1$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-head] # security released on head
[ruby-]1.9.3[-p547]
[ruby-]2.0.0-p451
[ruby-]2.0.0[-p481]
[ruby-]2.1.1
[ruby-]2.1[.2]
[ruby-]2.1-head
ruby-head

# GoRuby
goruby

# Topaz
topaz

# TheCodeShop - MRI experimental patches
tcs

# jamesgolick - All around gangster
jamesgolick

# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]

# JRuby
jruby-1.6.8
jruby[-1.7.12]
jruby-head

# Rubinius
rbx-2.0.0
rbx-2.1.1
rbx[-2.2.7]
rbx-head

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Kiji
kiji

# MagLev
maglev[-head]
maglev-1.0.0

# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head

# Opal
opal

# IronRuby
ironruby[-1.1.3]
ironruby-head

  -SVE1411EGXB:~/code/app1$ ruby -v
The program 'ruby' can be found in the following packages:
 * ruby
 * ruby1.8
Try: sudo apt-get install <selected package>
  -SVE1411EGXB:~/code/app1$ rvm use ruby --default
Using /home  /.rvm/gems/ruby-2.1.2
  -SVE1411EGXB:~/code/app1$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
  -SVE1411EGXB:~/code/app1$ rails s
=> Booting WEBrick
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
z atef
  • 7,138
  • 3
  • 55
  • 50
  • 2
    This probably is the more accurate answer. `rvm use 2.0.0 --default` fixed my issues. Thanks for the tip, have an upvote. – Tim Nov 14 '14 at 19:18
4

Are you making sure to source /usr/local/lib/rvm? echo 'source /usr/local/lib/rvm' >> ~/.bashrc and relog via SSH/start a new instance of Bash.


To clarify, since there is some confusion: there are two ways to install RVM: a "per user" install, and a "system wide" install.

For most day-to-day use, you want to use a "per user" install, which installs RVM into ~/.rvm. System-wide installs are good for servers, where one set of Rubies should be used. The default location for RVM in this case is /usr/local/rvm.

Based on your question, it appears you've installed RVM as a system-wide install.

To use RVM, it must be initialized by running a script each time you log in. To do this easily, you include the file in your ~/.bashrc file (or ~/.bash_profile if you're on OS X), so that it is automatically run each time you log in. For a per user install, add the following text to the file:

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

for system wide installs, use this text instead:

[[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"

If you do indeed have a system-wide install, you will also need to make sure you are a member of the rvm group; type the following to do so:

sudo adduser `whoami` rvm

Once you have made the necessary changes, log out of your session and then log back in. Once you have done so, rvm use 1.9.2 should set a bunch of environment variables, which you can see by typing rvm info. If all is well, ruby should execute correctly.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Michelle Tilley
  • 157,729
  • 40
  • 374
  • 311
  • Note: I spent several sessions trying to source `/usr/local/bin/rvm`, make sure it's `lib` instead of `bin` :) – Michelle Tilley Feb 06 '11 at 04:13
  • Could you clarify on what exactly you mean by "source /usr/local/lib/rvm". I'm new to ruby and ror in general and would really help if you could explain to me the terms. – YD8877 Feb 06 '11 at 04:15
  • RVM does not exist in `/usr/local/lib/rvm` any more. It now exists in `~/.rvm` in the user's home directory. You might want to check your version using `rvm -v`. The current rev is 1.2.6. – the Tin Man Feb 06 '11 at 04:20
  • Sourcing a file basically includes the contents of that script into the calling script, in this case, `.bashrc`, which is run each time you start bash. RVM needs to be initialized by sourcing that file. Check the bullet points below the system-wide-install instructions, namely, "You still need to edit the profile files like in a normal installation but instead of pointing to $HOME/.rvm/scripts/rvm you instead point it towards /usr/local/lib/rvm." "Post Install" section at http://rvm.beginrescueend.com/rvm/install/ has the specific instructions. – Michelle Tilley Feb 06 '11 at 04:22
  • Tin Man: That is correct for single-user installs. For **system wide installs**, the script goes into `/usr/local/lib/rvm`, as per https://github.com/wayneeseguin/rvm/blob/master/contrib/install-system-wide#L208 – Michelle Tilley Feb 06 '11 at 04:27
  • @the Tin Man: /usr/local/lib/rvm is the system wide rvm install directory and most certainly is still used. – Samuel Feb 06 '11 at 04:27
  • That is fine for the system-wide install, but that particular method is not recommended for normal users. Instead the normal use is to allow RVM to manage everything from `~/.rvm`, which is where it will go if the default `bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )` is used. – the Tin Man Feb 06 '11 at 04:30
  • 1
    While correct, the user's question has the output `Using /usr/local/rvm/gems/ruby-1.9.2-p136`, implying a system-wide install, not an install into `~/.rvm`. I answered accordingly. – Michelle Tilley Feb 06 '11 at 04:34
3

Ruby is not in your path. In simple terms, RVM handles the switching of Ruby in your path. Look at the output of the command-line tool

printenv

You should see something similar to:

PATH=/Users/myuser/.rvm/gems/jruby-1.5.6/bin

See Tin Man's response, it should get you were you need to go.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Jared Knipp
  • 5,880
  • 7
  • 44
  • 52
2

I noticed that source line was correctly in .bash_profile but I kept getting ruby command not found. So, when I checked rvm list, I figured out none ruby was selected:

rvm list

rvm rubies

   ruby-2.4.0 [ x86_64 ]

# Default ruby not set. Try 'rvm alias create default <ruby>'.

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

then I did the selection through rvm use 2.4.0 and checked again

rvm list

rvm rubies

=> ruby-2.4.0 [ x86_64 ]

# Default ruby not set. Try 'rvm alias create default <ruby>'.

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

Look the arrow close the installed ruby and the commented subtitles. After that ruby -v finally answered me

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]

I hope this help. Cheers.

edit: You can use rvm --default use 2.4.0 to set it as default ruby version

Shad
  • 1,021
  • 12
  • 21
1

I set my shell as a login shell (open terminal > Edit > Profile Preferences > Command tab > "Run command as a login shell") though I'm not 100% sure it's needed.

Once you're done installing RVM + Ruby though, you must specify which ruby you will be using. I like to use

rvm use --latest --default

James L.
  • 12,893
  • 4
  • 49
  • 60
1

rvm use 2.6.3 --default can fix it, but when I shut down my Ubuntu, the problem appearance once again!! this link helped me.https://github.com/rvm/rvm/issues/3682

  1. sudo vim .bash_profile
  2. add the following two lines:
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function    
风声猎猎
  • 1,065
  • 1
  • 7
  • 9