Fresh install of RVM in Ubuntu isn't letting me install gems (zlib error)
Asked Answered
F

3

16

Ok, I just created a fresh Ubuntu 11.04 install on Windows 7 using VirtualBox (not sure if this matters or not but just an fyi)

listing my rubies I get:

aaron@aaron-VirtualBox:~$ rvm list

rvm rubies

=> ruby-1.9.2-p290 [ x86_64 ]

but then trying to install the rails gem I get this:

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

What am I doing wrong?

Edit:
After doing what Dylan said my output (to prove those libraries are now installed):

aaron@aaron-VirtualBox:~$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
[sudo] password for aaron: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
autoconf is already the newest version.
bison is already the newest version.
build-essential is already the newest version.
git-core is already the newest version.
libc6-dev is already the newest version.
libncurses5-dev is already the newest version.
libreadline6 is already the newest version.
libreadline6-dev is already the newest version.
libsqlite3-0 is already the newest version.
libsqlite3-dev is already the newest version.
libssl-dev is already the newest version.
libxslt1-dev is already the newest version.
libyaml-dev is already the newest version.
openssl is already the newest version.
sqlite3 is already the newest version.
zlib1g is already the newest version.
zlib1g-dev is already the newest version.
curl is already the newest version.
libxml2-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
aaron@aaron-VirtualBox:~$ gem install rails
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
aaron@aaron-VirtualBox:~$
Following answered 3/8, 2011 at 0:58 Comment(0)
A
25

Run rvm notes and make sure to use apt-get to install the things RVM tells you to. It (something along the lines of zlib1g-devel will be one of them).

For Ubuntu, it should be something like this:

/usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

You might have to recompile your 1.9.2 afterwards (not 100% sure of that).

Aileneaileron answered 3/8, 2011 at 1:11 Comment(2)
Dylan, it wasn't working at first, but then I read the last part :D. I had to recompile. Now it works!Following
I couldn't get gem install to do anything until I ran sudo apt-get install libxml2-dev libxslt-dev. Didn't need to recompile; it just started working after that. Thanks.Lattermost
I
19

I found that we need to install package zlib after installing above packages(that rvm said). So we need to do:
rvm pkg install zlib
After that, re-install ruby. rvm reinstall 1.9.3
Run gem install rails
It will successfully install rails.

Interventionist answered 9/4, 2012 at 11:2 Comment(1)
me too! thanks! much quicker than apt-getting everything elseMarella
L
0

If you trust RVM you can run the following two commands. This

rvm requirements run
rvm reinstall all --force

Then the gem install rails command should work.

The first step will install all the packages that are needed for RVM. You do not normally need all, but it beats trying to search package by package.

Most people miss this part of the RVM install

Finally, see if there are any dependency requirements for your operating system by running:

user$ rvm requirements

Laryngotomy answered 16/2, 2013 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.