3

I'm new to Ruby on Rails. I'm trying to install rails on an ubuntu linux platform. I've already installed RVM and ruby. When I type

gem install rails --version 3.0.0

I get this error:

ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

Please help me install rails and learn a bit about the command line while I'm at it.

Matteo Alessani
  • 10,264
  • 4
  • 40
  • 57
Bodhidarma
  • 519
  • 1
  • 7
  • 25

3 Answers3

3

looks like you dont have ZLib installed. try gem install zlib and also apt-get install zlib zlib-dev if you dont have the system library installed

you need both the .so c-extension files (apt-get) and the ruby interface to them (gem )

also this may be the same thing as in Antother Stackoverflow Question

Community
  • 1
  • 1
loosecannon
  • 7,683
  • 3
  • 32
  • 43
  • Apparently I have to rvm install package zlib after removing ruby 1.9.2 but when i try to reinstall ruby after the process i get this: ERROR: Error running 'bunzip2 '/home/tom/.rvm/archives/ruby-1.9.2-p180.tar.bz2'', please read /home/tom/.rvm/log/ruby-1.9.2-p180/extract.log the process continues but it gets stuck in the compiling process. – Bodhidarma Jun 20 '11 at 16:19
  • what does the log say? what happened to bzip? – loosecannon Jun 20 '11 at 17:04
2

I guess you need zlib package to install rails. try

rvm pkg install zlib

after that

sudo apt-get install zlib1g

and then the development package. not sure why but you need it.

sudo apt-get install zlib1g-dev

then remove the current version of ruby because you didn't have zlib when ruby was compiled. type

rvm remove 1.9.2

(replace 1.9.2 with your version) and then install it again with

rvm install 1.9.2

(again your version here)

That's basically it. I had the same error and it worked for me, hope it helps you too.

d0ragon
  • 27
  • 3
0

This has happened to me a few times. The answers near the bottom should fix it, but unfortunately you will need to remove and then recompile ruby :(
I have never gotten it to work without totally removing ruby.

http://ubuntuforums.org/showthread.php?t=1494997

mraaroncruz
  • 3,780
  • 2
  • 32
  • 31