1

I didn't know that installing ruby is such a pain After lot of trouble with curl certificate, I installed the rvm using the methods mentioned in the rvm site also with lot of help from stackoverflow questions. Now I am trying to install rails using the gems command

gem install rails

but I always get this error

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

I did follow every thing mentioned here https://rvm.beginrescueend.com/packages/zlib/ and also as a mentioned in a stackoverflow post

I did install all the tools as required by the requirements

   yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel

But still I get this error. When I looked at the build log for ruby under /usr/local/rvm/log/ruby-1.9.3-p125/configure.log I see this error

  [2012-04-07 01:13:44]  ./configure --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p125 --enable-shared --disable-install-doc --with-zlib --with-opt-dir=/usr/local/rvm/usr --with-libyaml
  configure: WARNING: unrecognized options: --with-zlib, --with-libyaml

Is the rvm broken ? or is there a problem while building the ruby src.

Note: I am running fedora 14

Srikan
  • 2,161
  • 5
  • 21
  • 36

1 Answers1

4

RVM causes more problems than it solves (IMHO). Better tools are ruby-build and rb-env. Newer tools that look very good too are ruby-install and chruby.

Here are my notes from my recent Red Hat Enterprise Linux (RHEL) installation of Ruby, which I believe is pretty similar to Fedora. Perhaps these notes can be of some help to you. Ask me questions if you like.

Install zlib

yum install zlib zlib-devel

Install YAML

export k=yaml v=0.1.4
wget http://pyyaml.org/download/libyaml/$k-$v.tar.gz
tar zxvf $k-$v.tar.gz
cd $k-$v 

./configure
make && make install

Install X11 if you want X or headless browsing for testing

yum install 
  xorg-x11-fonts-misc
  xorg-x11-fonts-truetype
  xorg-x11-server-Xorg
  xorg-x11-server-Xvfb

Install libraries

yum install 
  gdbm gdbm-devel
  ncurses ncurses-devel
  openssl openssl-devel
  readline readline-devel
  tk tk-devel
  libjpeg libjpeg-devel
  libpng libpng-devel
  libxml2 libxml2-devel
  libxslt libxslt-devel
  zlib zlib-devel

Install ruby-build

cd /opt
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build/
./install.sh

Install Ruby

export k=ruby v=1.9.3-p125
wget http://ftp.ruby-lang.org/pub/ruby/1.9/$k-$v.tar.gz
tar zxvf $k-$v.tar.gz
cd $k-$v

# Either onfigure with defaults...
./configure 

# Or configure with custom locations...
./configure --prefix=/opt/$k/$v --enable-shared --with-opt-dir=/opt/yaml/current

make && make check && make install

Environment

Edit /etc/environment to add this:

RUBYOPT='-r rubygems -r psych'

If you put Ruby in a custom directory, also merge this with your existing path:

PATH=/opt/ruby/1.9.3-p125/bin  (or wherever you put it)

Load environment:

source /etc/environment

Verify gem runs and you see the intial set of gems:

gem list

Gem update:

gem update --system
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
  • Thank you for the ruby-build and rb-env advice. Thumb up, upvote. – Green Mar 14 '13 at 21:49
  • Awesome! following it up right now, just one question would this work for all users in the system? I'm doing it with root. – orlybg May 03 '13 at 20:09
  • What happens if I already had a version of ruby installed with the system (ruby 1.8.5) ? – orlybg May 03 '13 at 21:13
  • @orlybg You have choices: you can use rbenv to install Ruby system-wide, or per-user. Either way is good depending on your goals. I do system-wide on my servers, and per-user for my desktop-style systems. – joelparkerhenderson May 06 '13 at 04:32
  • Oopse @joelparkerhenderson I had same issue and followed all these instructions. Here is the result: "gem list" works but "gem update --system" returns same error "cannot load load such file -- zlib" – WSK Jan 14 '14 at 07:22
  • @WSK have you seen this about loading zlib? It may help you: http://stackoverflow.com/questions/9727908/cannot-load-such-file-zlib-even-after-using-rvm-pkg-install-zlib – joelparkerhenderson Jan 17 '14 at 01:27