Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Rails Path on Ubuntu with RVM

Tags:

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?

like image 978
user424703 Avatar asked Aug 19 '10 02:08

user424703


People also ask

Where is RVM installed Ubuntu?

Single-User Install Location: ~/. rvm/ If the install script is run as a standard, non-root user, RVM will install into the current users's home directory.


2 Answers

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"

like image 195
scaganoff Avatar answered Sep 21 '22 15:09

scaganoff


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.

like image 43
Rob Di Marco Avatar answered Sep 18 '22 15:09

Rob Di Marco