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?
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"
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.
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
Uninstall ruby
rvm remove ruby-1.9.2
Install the necessary libraries
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
Reinstall ruby
rvm install 1.9.2
You will probably want to set this version of ruby as default
rvm use 1.9.2 --default
Just to be safe, close the terminal you currently have open and open a new one. You should be good to go from here.
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!
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
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
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
See: RVM Ruby 1.9.1 install can't locate zlib but its runtime and dev library are there
first, Install the necessary libs
sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
then, Reinstall ruby 1.9.2
rvm reinstall 1.9.2 && rvm use 1.9.2
精彩评论