ItGo.me Focus on IT Recommend

Home > Installing Rails Path on Ubuntu with RVM

Installing Rails Path on Ubuntu with RVM

I'm a linux noob running Ubuntu 10.04 and trying to install rails. I first installed ruby and then RVM and then downloaded and installed rubygems and then installed rails.

Rails only seems to respond if I have a 'sudo' in front of the command. If I write 'rails new test' in the terminal I get this:

/usr/local/lib/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:214:in `activate'
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:1082:in `gem'
    from /usr/bin/rails:18

If I go to the terminal and write 'rails -v' I get the same thing:

   /usr/local/lib/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:214:in `activate'
        from /usr/local/lib/site_ruby/1.8/rubygems.rb:1082:in `gem'
        from /usr/bin/rails:18

And if I go to the terminal and write 'sudo rails -v' I get the following: Rails 3.0.0.rc

'gem environment' gives me this:

RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.2 (2010-07-11 patchlevel -1) [i686-linux]
  - INSTALLATION DIRECTORY: /home/josh/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial
  - RUBY EXECUTABLE: /home/josh/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby
  - EXECUTABLE DIRECTORY: /home/josh/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial/bin

My suspicion is that my path is not set up correctly but I'm not sure how to fix it. Suggestions?

ruby-on-rails ubuntu rvm
|
  this question
edited Oct 20 '11 at 20:14 Frank Shearar 14.4k 6 49 77 asked Aug 19 '10 at 2:33 user424703 131 1 1 4

 | 

9 Answers
9

I also experienced this problem on a clean install of Ubuntu 10.10...even after installing the rvm and ruby pre-requisites documented by "$ rvm notes".

It appears to be a problem with the "rvm" gem installation being unable to find the system zlib installation. Daniel's comment above is a great comment - a pity it is not listed as an answer.

So the solution for me was to follow the instructions pointed out by Daniel at: https://rvm.beginrescueend.com/packages/zlib/.

$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2

The first command install zlib locally into your rvm area. The second command removes ruby 1.9.2 and the third command reinstalls ruby 1.9.2 with the rvm-local zlib.

Thereafter set your ruby version and install gems:

$ rvm use 1.9.2
$ gem install "whatever"


|
  this answer
edited Oct 19 '11 at 5:45 garrow 2,773 1 14 23 answered Apr 17 '11 at 7:37 scaganoff 1,630 13 15 2   I had to use the following variant: rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr –  James Bloomer Oct 21 '11 at 22:29      I had to remove the ruby platform first before proceeding with the installation of zlib –  Sumit Bisht Feb 3 '12 at 20:19

 | 

My guess is that you installed your gems using sudo (e.g. sudo gem install rails). When you use sudo to install, RVM is being ignored and the system ruby is being used.

When using RVM, you really don't want to install with sudo (note there is a command rvmsudo, to run your RVM setup through sudo, but you really rarely will use this). As you can see from your environment, your gems will be stored in /home/josh/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial/gems, where you do not need root permissions to install.

So try:

gem install rails

as yourself and see if everything is working.


|
  this answer
answered Aug 19 '10 at 3:23 Rob Di Marco 28.4k 6 49 48      thanks, I just tried 'gem install rails' and received this: ERROR: Loading command: install (LoadError) no such file to load -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand any idea? –  user424703 Aug 20 '10 at 0:58      Sounds like you do not have zlib installed on your machine. This is a dependency of libssl, so I would recommend doing an aptitude install openssl and then retry –  Rob Di Marco Aug 20 '10 at 1:55      Thanks for the help... I ran 'aptitude install openssl'... i reinstalled rubygems and ran 'gem update --system' and got this error : "ERROR: Loading command: update (LoadError) no such file to load -- zlib" I also tried ' gem install rails --version 3.0.0' and received the very similar "ERROR: Loading command: install (LoadError) no such file to load -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand" ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::UpdateCommand" Any ideas what I can do? –  user424703 Sep 7 '10 at 3:38 12   user424703 check out rvm.beginrescueend.com/packages/zlib worked for me :-) –  Daniel Bower Sep 14 '10 at 2:11

 | 

If you are getting this warning, "ERROR: Loading command: update (LoadError) no such file to load -- zlib"

Basically, if the zlib library isn't there at the time you compile ruby, you just have to go back and install the library and then re-compile ruby.

So try these steps

  1. Uninstall ruby

    rvm remove ruby-1.9.2

  2. Install the necessary libraries

    sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev

  3. Reinstall ruby

    rvm install 1.9.2

  4. You will probably want to set this version of ruby as default

    Recommend:ruby - Installing Rails 3.0.9 on Ubuntu 10.10 with RVM - no rails command in path

    em and with different (newer) versions (hence, the new question). On a moderately fresh installation of Ubuntu 10.10 Maverik, I attempted to install Rails using RVM as I have done on other distributions before. Here are roughly the steps I

    rvm use 1.9.2 --default

  5. Just to be safe, close the terminal you currently have open and open a new one. You should be good to go from here.


|
  this answer
answered Oct 18 '11 at 17:22 Ryan 6,179 5 29 39

 | 

As Rob Di Marco stated above, you cannot use sudo gem install rails with RVM (see the RVM Documentation).

I actually just asked a very similar question. I initially installed rails with sudo gem and when I attempted to install an older version of rails using RVM I ran into this issue. This was my code:

rvm use 1.8.7
rvm gemset create rails3.0.1
rvm 1.8.7@rails3.0.1
sudo gem install rails --version=3.0.1 #the *sudo* in this line is WRONG

Another user (zetetic) suggested to uninstall your "sudo gem rails" with the following command:

sudo gem uninstall rails

And then install again without sudo - gem install rails

After I did all of this I retried my original code and it worked, but this time without sudo:

rvm use 1.8.7
rvm gemset create rails3.0.1
rvm 1.8.7@rails3.0.1
gem install rails --version=3.0.1

The code above may only be relevant to you if you are attempting to use RVM, but to solve your problem, try uninstalling your sudo rails and re-installing without sudo. Worked for me. Good luck!


|
  this answer
answered Dec 7 '10 at 3:00 mmichael 6,111 10 31 53

 | 

The solution is :

apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev

Then :

rvm install ruby-1.9.2-p290
rvm default 1.9.2

|
  this answer
answered Jul 25 '11 at 0:21 Unitech 2,238 1 25 37

 | 

No, all my gems are installed without sudo.

Here are some debug information that may help.

$PATH before rvm 1.9.2 --passenger

/home/kevin/.rvm/gems/ruby-1.9.2-p0/bin: /home/kevin/.rvm/gems/ruby-1.9.2-p0@global/bin: /home/kevin/.rvm/rubies/ruby-1.9.2-p0/bin:/home/kevin/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games

$PATH after rvm 1.9.2 --passenger

/home/kevin/.rvm/gems/ruby-1.9.2-p0/bin: /bin:/home/kevin/.rvm/rubies/ruby-1.9.2-p0/bin:/home/kevin/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

This is my .bashrc file: http://pastebin.com/H9U3azAk


|
  this answer
answered Sep 12 '10 at 21:17 Kevin Sjöberg 1,685 9 15

 | 

if you are installing through source

ext/Setup and uncomment the zlib line

$ ./configure
$ make
$ sudo make install

$ ruby -v
=> ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

$ gem -v
=> 1.3.7

|
  this answer
answered Nov 6 '10 at 13:11 Mayank Jain 180 3 15

 | 

See: RVM Ruby 1.9.1 troubles


|
  this answer
answered Nov 28 '10 at 3:17 Craig Norton 655 1 8 20

 | 
  1. first, Install the necessary libs

    sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev

  2. then, Reinstall ruby 1.9.2

    rvm reinstall 1.9.2 && rvm use 1.9.2


|
  this answer
answered Jun 8 '12 at 12:59 hahakubile 1,945 1 16 17

 | 

Recommend:ruby on rails - Installing RVM on Ubuntu

an it first with: $ sudo apt-get --purge remove ruby-rvm

oriUlr:http://stackoverflow.com/questions/3518294/installing-rails-path-on-ubuntu-with-rvm

------splitte line----------------------------