Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install rubygems with ruby 2.0.0

I've been trying to install rubygems for hours, but it keeps failing. The error is:

Installing rubygems-2.0.3 for ruby-2.0.0-p0..............................................................................................................................
Error running 'env GEM_PATH=/Users/Chris/.rvm/gems/ruby-2.0.0-p0:/Users/Chris/.rvm/gems/ruby-2.0.0-p0@global:/Users/Chris/.rvm/gems/ruby-2.0.0-p0:/Users/Chris/.rvm/gems/ruby-2.0.0-p0@global 
GEM_HOME=/Users/Chris/.rvm/gems/ruby-2.0.0-p0 /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/bin/ruby -d /Users/Chris/.rvm/src/rubygems-2.0.3/setup.rb --verbose',
please read /Users/Chris/.rvm/log/ruby-2.0.0-p0/rubygems.install.log

(Sorry if that's difficult to read, I'm not exactly sure how to break it up.)

rubygems.install.log:

Top few lines:

[2013-03-21 06:55:13] /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
Exception `LoadError' at /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1073 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/ruby
mkdir -p /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0
mkdir -p /Users/Chris/.rvm/rubies/ruby-2.0.0-p0/bin

Full file: Pastebin

I've tried reinstalling Xcode, made sure I've install xcode command line tools, Rvm, ruby 2.0.0, pretty much everything. I've also tried removing all the other ruby versions and rvm requirements doesn't tell me I need anything I don't have.

Does anyone know what could be causing this?

EDIT: Also, I just managed to reinstall 1.9.3, with rubygems 1.9.3, absolutely fine.

EDIT2: Okay, now I'm getting the error:

/Users/Chris/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- zlib (LoadError)

in the log.

Edit 3: Ran rvm requirements, nothing I didn't have already. Trying to install zlib gives me errors with configure and make.

Configure:

unknown option: --disable-shared

Make:

make: *** No rule to make target `install'.  Stop.

Trying to configure and make manually (without the disable shared flag) removes the configure issue but leaves the make issue.

Edit 4:

So after a trying several different things, it suddenly worked. I decided to try rvm one last time, and everything worked fine. I'd post what I did, but I really have no idea.

like image 592
CSturgess Avatar asked Mar 21 '13 11:03

CSturgess


3 Answers

I think you are missing some libraries while installing ruby type

rvm requirements

and see which libraries you are missing and install the same, in particular install the zlib pkg and also you need to re install ruby

rvm pkg install zlib
rvm reinstall ruby

I am using ubuntu so I can install the libraries like this

sudo apt-get install zlib1g-dev
rvm reinstall ruby
like image 112
Mansoor Elahi Avatar answered Sep 27 '22 17:09

Mansoor Elahi


Refer to this question Troubles with ruby-2.X installation using RVM

pretty much

$ rvm remove 2.0.0 # get rid of unsuccessful installation
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install ruby-2.0.0
like image 25
Leo Correa Avatar answered Sep 27 '22 18:09

Leo Correa


I tried

$ rvm remove 2.0.0 # get rid of unsuccessful installation
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install ruby-2.0.0

But it didn't work. Ruby 2.0.0 seems to be installed successfully.

I open a new terminal, then

rvm use 2.0.0
rvm rubygems latest 

It works. Hope it helps

like image 37
DungHuynh Avatar answered Sep 27 '22 18:09

DungHuynh