Error in ruby: cannot load such file -- zlib - ruby

When I try to install rails in Ubuntu 12.10 I get this error:
$ gem install rails
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
So I completely removed rvm:
rvm implode
sudo rm -rf ~/.rvm
removed the script calls in my .bashrc and .bash_profile
and checked if they're really removed:
env | grep rvm #no output, so rvm is removed
ruby -v #The program 'ruby' can be found in the following packages: blabla
I already have these via sudo apt-get install:
curl zlib1g-dev zlib1g libssl-dev build-essential openssl libreadline6 libreadline6-dev curl git-core libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
Then proceed to install from scratch
curl -L https://get.rvm.io | bash -s stable --ruby --auto-dotfiles
then run that line and restarted terminal regard to this message:
* To start using RVM you need to run `source /home/adige/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Then rvm pkg install readline but completed with error:
...
Error running 'autoreconf -is --force', please read /home/adige/.rvm/log/readline/autoreconf.log
...
Please note that it's required to reinstall all rubies:
rvm reinstall all --force
I think it's installed anyway, right? Before reinstall all rubies, I installed zlib of course:
# w/out verify, it gives checksum error
rvm pkg install zlib --verify-downloads 1
Then run rvm reinstall all --force and completed with error again:
...
Install of ruby-1.9.3-p374 - #complete
Making gemset ruby-1.9.3-p374 pristine.
Error running '' under ,
please read /home/adige/.rvm/log/ruby-1.9.3-p374/gemset.pristine.log
Making gemset ruby-1.9.3-p374#global pristine.
gemset.pristine.log
Then reinstall ruby with zlib support:
rvm reinstall 1.9.3-p374 --with-zlib-dir=$rvm_path/usr
which returned same error and same log but completed anyway.
Finally I tried to install rails gem again but cannot load such file -- zlib !
Here is the rvm info
What am I doing wrong?

You should not install readline / zlib on ubuntu, follow this steps:
rvm get head
rvm pkg remove
rvm requirements run force
rvm reinstall 1.9.3-p374
make sure to include output of the installation process if this fails, also include all mentioned log files

Related

Installing latest RUBY with rvm gives error on Ubuntu

Getting the following error when im trying to install ruby-2.1.2
rvm install ruby-2.1.2
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/ubuntu/12.04/x86_64/ruby-2.1.2.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system................
Error running 'requirements_debian_update_system ruby-2.1.2',
showing last 15 lines of /usr/local/rvm/log/1400060285_ruby-2.1.2/update_system.log
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'There has been error while updating '\''apt-get'\'', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
\n'
There has been error while updating 'apt-get', please give it some time and try again later.
For 404 errors check your sources configured in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
++ return 100
sudo apt-get install gawk g++ gcc make libc6-dev libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev
I think your rvm is older version,
Install the latest (v1.25.25) rvm using:
$ \curl -L https://get.rvm.io | bash -s stable --ruby
then check the rubies available with this version:
$ rvm list known
then install the latest:
$ rvm install ruby-2.1.2
Note: Even if it does not show up in rvm list known it will try to download with the following message:
Installing Ruby from source to: /home/<YOUR_USER_NAME>/.rvm/rubies/ruby-2.1.2, this may take a while depending on your cpu(s)...
This error in my case was cased because apt-get update gave a n error. After doing and manual sudo apt-get update I notices that one of the repos gave an error "W: Failed to fetch". After editing the repo list and removing the one that gave the error I was able to install.
Try to use this for install latest ruby
rvm mount -r https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-1.9.3-p194.tar.bz2
for more help
rvm help mount
I tried most of above answers but none works for me, so i just change server
If you are using rvm for ruby then this will work.
Goto directory etc/apt
click on Sources.list
Change the server to us or some else server
Reload (it will update your cache from that server)
Then run sudo apt-get update
Finally run rvm install 2.3.0

RVM installed but not working?

I installed RVM on my Fedora 19 system a few months ago, and it was working fine. Then I had some other work and when I opened the machine again, it said:
# rvm
bash: rvm: command not found...
I tried to reinstall RVM, and this is what I get:
# rpm -i rvm-devel-1.17-8.fc19.x86_64.rpm
package rvm-devel-1.17-8.fc19.x86_64 is already installed
But I can't find it.
# ps ax | grep rvm
14363 pts/0 S+ 0:00 grep --color=auto rvm
Can anyone help me? What exactly is the problem?
P.S: The package rvm is there on the system.
# rpm -q rvm
rvm-1.17-8.fc19.x86_64
I recommend you to reinstall RVM, maybe it's crashed due to some event.
Use this command to implode it:
rvm implode
Or:
rm -rf ~/.rvm
Then install it by running:
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable --auto
Then you'll need to reload the ~/.bash_profile file which you can do with this small command:
. ~/.bash_profile
Make sure to install other packages needed for Ruby to work:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
sudo apt-get install pkgconfig
Now install the latest Ruby:
rvm install 2.0.0
rvm use 2.0.0
ruby -v
Now you can install Rails:
gem install rails -v 4.0.0
the package rvm-devel-1.17-8.fc19.x86_64 is not rvm as per http://rpm.pbone.net/index.php3/stat/4/idpl/20537074/dir/fedora_19/com/rvm-devel-1.17-8.fc19.x86_64.rpm.html it is:
The rvm-devel package contains libraries and header files for
developing applications that use rvm.
Follow installation instructions http://rvm.io/rvm/install to get RVM installed, make sure to read the outputs as important hints might be printed for you.
to uninstall rvm use anyone of the following:
rvm implode
or
rm -rf ~/.rvm
Just to be sure restart the terminal before you try installing rvm again

Install Ruby via RVM without confirmation prompt

I use Puppet to install Ruby via RVM and was working fine until very recently (last few days or so).
I think its due to rvm wanting me to "press any key to continue". Is there anyway to force "yes" this, I've tried --force but no luck. Thanks
[root#local ~]# rvm install --binary --verify-downloads 1 ruby-1.9.3-p362
Searching for binary rubies, this might take some time.
Installing requirements for unknown, might require sudo password.
Always update your system first!
/bin/bash
/usr/bin/curl
which: no git in (/usr/local/rvm/gems/ruby-1.9.3-p362/bin:/usr/local/rvm/gems/ruby-1.9.3-p362#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p362/bin:/usr/local/rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin)
/usr/bin/patch
Install: git
Install: build-essential openssl libreadline zlib1g libyaml libsqlite3 sqlite3 libxml2 libxslt autoconf libc6 libgdbm ncurses automake libtool bison pkg-config
press any key to continue
Try:
$ yes | rvm install --binary --verify-downloads 1 ruby-1.9.3-p362
From yes's man page:
Repeatedly output a line with all specified STRING(s), or ‘y’.
this message is from the new autolibs feature of RVM, you can find docs of it here: https://rvm.io/rvm/autolibs
You can disable autolibs using:
rvm autolibs disable
and make sure to report back to RVM it did not recognize your system => https://github.com/wayneeseguin/rvm/issues ... make sure to include head -n 100 /etc/*release (run as user not root)

cannot load such file -- zlib even after using rvm pkg install zlib

I installed zlib package and ruby 1.9.3 using rvm, but whenever I try to install
gems it says
cannot load such file -- zlib
The commands I used to install are
$ rvm install 1.9.3
$ rvm pkg install zlib
$ rvm reinstall 1.9.3 --with-readline-dir=/home/username/.rvm/usr \
--with-iconv-dir=/home/username/.rvm/usr \
--with-zlib-dir=/home/username/.rvm/usr \
--with-openssl-dir=/home/username/.rvm/usr
$ rvm use 1.9.3
$ gem install heroku
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
All the help on this subject tells me to just do rvm pkg install zlib, and
then reinstall the ruby with --with-zlib-dir=/home/username/.rvm/usr, but this
didn't work.
I ended up installing zlib from apt-get and then reinstalling ruby to not use the rvm directory for zlib.
Here's how do:
$ sudo apt-get install zlib1g-dev
$ rvm reinstall 1.9.3
[Edit] As commenter #chrisfinne mentions, on CentOS/RedHat based systems:
$ sudo yum install zlib-devel
$ rvm reinstall 1.9.3
The both other responses were almost right...
The rvm site for zlib provides a quick fix!
On the top off the page is a "Quick fix" follow it's instructions, it will:
fix your installation,
provide you instructions what to do to install zlib from your system
and show how to reinstall ruby
Use autolibs to install dependencies:
rvm autolibs enable
rvm reinstall 1.9.3
RVM will automatically install missing dependencies and use them for compiling ruby.
More details on autolibs => http://rvm.io/rvm/autolibs
The solution that worked for me is described in rvm github repo, issue #3389.
Run
rvm install 2.3.0 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8
for ruby 2.3.0 version.
Ruby has a bunch of package dependencies like the one on zlib-devel. They're nasty because there's nothing to indicate you need the library until get some obscure error message while trying to do something routine.
The solution is to use rvm. Use it even if you only need one version of ruby. Why? Because then you can do
rvm requirements
This will probe your particular OS and produce a set of commands you can copy back to the command line to install those missing packages.
rvm pkg install openssl && rvm pkg install zlib && rvm pkg install libyaml &&
rvm pkg install iconv
rvm install 1.9.3-p0 --with-opt-dir=$HOME/.rvm/usr \
--with-libxml2-dir=/usr/local/Cellar/libxml2/2.7.8 \
--with-readline-dir=/usr/local/Cellar/readline/6.2.1

Installing OpenSSL on Ubuntu for Rails development?

I am running the latest RVM on Ubuntu 10.10 and I managed to get most of the development environment running, except for OpenSSL.
When I try to install the package I get the following error:
$ rvm package install openssl > error
ERROR: Error running 'tar zxf /home/ruby/.rvm/archives/openssl-0.9.8n.tar.gz -C
/home/ruby/.rvm/src', please read /home/ruby/.rvm/log/openssl/extract.log
ERROR: Error running './config -I/home/ruby/.rvm/usr/include -L/home/ruby/.rvm
/usr/lib
--prefix=/home/ruby/.rvm/usr zlib no-asm no-krb5 shared ', please read /home/ruby
/.rvm/log/openssl/configure.log
ERROR: Error running '/usr/bin/make ', please read /home/ruby/.rvm/log/openssl/make.log
ERROR: Error running '/usr/bin/make install', please read /home/ruby/.rvm/log/openssl
/make.install.log
It seems that the original downloaded file is corrupt when I get it via RVM. So, I downloaded and unpacked it to ~/.rvm/src/openssl0.9.8 and the first error is gone (error running tar zxf), but I still get the other ones.
Edit: my Ruby version, if anyone cares, is:
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
Did you run rvm requirements after installing RVM? It shows a list of all needed dependencies, and supplies the recommended "apt-get" command.
/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
This will install openssl and libssl-dev, both of which are required. I've installed RVM and Ruby many times on Ubuntu and always used RVM's recommended way without a problem.
Do you have libssl installed in Ubuntu?
sudo apt-get install libssl0.9.8
Also install the development package:
sudo apt-get install libssl-dev

Resources