Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM installed by Ruby not working?

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 ([email protected]) [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]# 
like image 420
YD8877 Avatar asked Feb 06 '11 04:02

YD8877


People also ask

How do I start RVM?

To start using RVM for the first time, run the following in the terminal. This only needs to be run once after installation. This command will execute the rvm.sh script and allow you to run RVM in the current terminal.

How do I install Ruby on RVM?

To install a version of Ruby using RVM, use the command rvm install <version number>. So to install version 2.6.3 of Ruby enter the following into the terminal: Depending on your operating system, the above command may use precompiled binaries or compile the Ruby binaries from source. If compiling from source, this may take a long time to complete.

What is Ruby Version Manager (RVM)?

Ruby Version Manager (RVM) attempts to solve this problem. Ruby Version Manager (RVM) creates an isolated installation of Ruby in your $HOME directory. This concept makes it easy to run multiple versions of Ruby at the same time, and removing it is as easy as deleting one folder.

How do I know if RVM is working correctly?

To make sure RVM is working correctly, instruct RVM to return the currently installed version by entering the following into the terminal: This command will show the current version of RVM installed on the operating system. If the installation was successful, the output should be similar to the following, but may display a different version:

What happens if RVM is not installed?

If that version isn’t installed, then the output from the terminal will be as follows: Required ruby-2.6.2 is not installed. Now that you have RVM installed and are able to switch between different versions, it should remove some of the headache when configuring your system. However, this is just the tip of the iceberg.


2 Answers

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.

like image 148
the Tin Man Avatar answered Sep 23 '22 08:09

the Tin Man


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.

like image 43
Micael Queiroz Avatar answered Sep 26 '22 08:09

Micael Queiroz