views:

758

answers:

3

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?

+2  A: 

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.

Rob Di Marco
thanks, I just tried 'gem install rails' and received this:ERROR: Loading command: install (LoadError) no such file to load -- zlibERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommandany idea?
Sounds like you do not have zlib installed on your machine. This is a dependency of libssl, so I would recommend doing anaptitude install openssland then retry
Rob Di Marco
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 -- zlibERROR: 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 check out http://rvm.beginrescueend.com/packages/zlib/ worked for me :-)
Daniel
A: 

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

Kevin Sjöberg