[gkaykck#main myApplication]$ rails console
/usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
from /usr/local/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:20:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed rails 3 on ruby 1.9.2p136, which is ok i guess. But i cannot start rails console and it gives me the error i copied. The apps worked great with ruby 1.8.7 and i never saw an error like this.
Any ideas what it could be?
Apparently ubuntu and ruby don't always catch dependencies like they should.
From the first google hit (yeah, I clicked on this stack-overflow in place #2 before checking out the first result.)
Navigate to the Ruby source and enter:
sudo apt-get install libreadline5-dev
cd ext/readline
ruby extconf.rb
make
sudo make install
So, if you're on another distro, make sure you install readline somehow (source/package), then run make/install on extconf from the source. I tried what gkaykck suggested of course but got this without readline already on my system.
$ ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no
checking for editline/readline.h... no
Recipe for those who use rvm:
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
In more details about it on https://rvm.io/packages/readline/
If you want another solution to this problem do this.
sudo apt-get install libreadline6
Then in your gem file add:
gem 'rb-readline'
Then
bundle install
And you should be all set.
I'd recommend using rvm (Ruby Version Manager) to manage your different versions of Ruby and switch between them. It does a pretty good job of compiling the various versions for you too. You can even create per-directory .rvmrc files to tell rvm what version of ruby to use in which directory (as well as use per-project gem sets if you want!)
First of all uninstall every ruby version you have.
After that display rvm requirements:
rvm requirements
You will get something like:
Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10" )
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
bash >= 4.1 required curl is required git is required (>= 1.7 for
ruby-head) patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you
must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
ruby: /usr/bin/apt-get install build-essential 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 automake libtool bison subversion
# For JRuby, install the following:
jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
ironruby: /usr/bin/apt-get install curl mono-2.0-devel
Install all dependencies via apt-get.
After that install ruby 1.8.7. This version is required if you plan to use ruby 1.9.x
Now you can install ruby 1.9.3:
rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr
Note that you dont even need to install readline package via rvm if you had installed it using apt-get.
With CentOS 6:
Remember we are working from the ruby install dir, for me it was:
/opt/ruby-1.9.3-p194/ext/readline
If you see the following output, then readline is not installed:
$ ruby extconf.rb
checking for tgetnum() in -lncurses... no
checking for tgetnum() in -ltermcap... no
checking for tgetnum() in -lcurses... no
checking for readline/readline.h... no
checking for editline/readline.h... no
To install with RPM:
yum install readline-devel
Then build it:
ruby extconf.rb
make
sudo make install
Adding in the Gemfile
gem 'rb-readline'
and then bundle install
did the trick for me
Solution is to go to the source folder you compiled ruby => ext => readline than
ruby extconf.rb
make
sudo make install
If you're using RVM you can re-make readline. This fixed the issue for me. Instructions here:
no such file to load -- readline (Load Error)
use rvm remove to remove all ruby installed.
do a "which ruby" if you still get something, you need to reinstall rvm then install ruby using rvm.
Related
I am trying to install Ruby on Rails on my local machine for development purposes, but I have hit upon an error. I can't quite tell, but it seems like it might be a gem error. Though, this is my first time trying to use all three, Ruby, Gem and Rails, so I'm not sure.
Running the command "sudo gem install rails -V" these are the last few lines printed after the error is hit:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:13:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/atomic-1.1.14 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/atomic-1.1.14/ext/gem_make.out
The version of Ruby installed is:
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
The version of gem is:
1.8.23
Install the gem as a normal user, not sudo:
gem install rails
Or install the ruby dev package. There are a lot of similar answers in SO:
Failed to build gem native extension — Rails install
Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
From the atomic gem README.
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic
Please install Java, then re-run the gem install process.
What Linux do you have?
On Mint, i did:
sudo apt-get install git
sudo apt-get install curl
curl -L https://get.rvm.io | bash -s stable --ruby
sudo apt-get install git-core
source ~/.rvm/scripts/rvm
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm autolibs enable
rvm reload
rvm requirements
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
rvm install ruby-2.0
curl -L https://get.rvm.io | bash -s stable --rails
and it works fine. This will (currently) install Ruby 2.0 and rails 4.0 however.
I'm getting
ERROR: While executing gem ... (NameError) uninitialized constant Gem::RemoteFetcher::OpenSSL
When I try to run # gem install rails
I already have
Ruby v1.8.7
Gem (rubygems.nonarch) v1.7.2
Installed.
Any Idea what I should do?
Running sudo gem install rails now gives me:
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.7.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.7.4/ext/json/ext/generator/gem_make.out
Everything Installed via YUM
Running Fedora 15
I was having a similar issue while doing #gem install rake, but I found out that my system was behind a proxy server, and so I tried supplying the proxy address by this command:
gem install rake -p http//IPaddress:proxyport (put : after http)
and it worked for me, with no such error afterwards.
Hit rvm requirements. You don't have libssl-dev installed.
➜ ~ rvm requirements
Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10" )
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
ruby: /usr/bin/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
# For JRuby, install the following:
jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
ironruby: /usr/bin/apt-get install curl mono-2.0-devel
I'm not aware how Fedora's requirements differ from Ubuntu's, but that's probably only in package names.
I have just had same issue with gem install on Ubuntu. It is now working and I think that what I did to fix it was enable ssl out through the firewall.
It looks as if gem returns this error in response to failure to establish an SSL connection, presumably while trying to handle the failure.
Russell
I used rvm to install ruby 1.9.3. even though it was successfully installed, it complained about libyaml. and now every time i wanna install a gem (say rails) this warning shows up:
It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.
I use Mac os X 10.7 (Lion).
In my case
rvm pkg install libyaml
and
rvm reinstall ruby-1.9.3-p125
solved the problem.
For people using Ubuntu, make sure that libtool is installed prior to the steps above:
sudo apt-get install libtool
For macOS users (with homebrew):
rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby
brew install libyaml
rvm reinstall 1.9.3
Is what worked for me (on Snow Leopard).
for ubuntu and rvm
sudo apt-get install libtool
rvm pkg install libyaml
rvm reinstall 1.9.3
worked
If not using rvm, but rather you are building and installing ruby 1.9.3 from scratch — for example, you're managing your ruby versions with rbenv — you must install libyaml first. Get it from http://pyyaml.org/; at the moment, the file you want is http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz. Open the tarball and cd into the resulting folder. Then:
./configure --prefix=/usr/local
make
sudo make install
You are now ready to build ruby. Download ruby from http://ftp.ruby-lang.org/pub/ruby/. Open the tarball and cd into the resulting folder. Now:
./configure --prefix=/wherever/you/want/it/to/go
make
make install
(Or possibly sudo make install, depending on where you're putting it.) If using rbenv, you'll know it has worked if you switch to rbenv global 1.9.3-p194 (or whatever your version is called) and gem --version works without a warning. That worked for me on Mac OS X 10.6.8. (Update: I just tried this on Mac OS X 10.8.1 and it seems to have worked fine there too.)
In my case the solution was to add the psych gem to the Gemfile.
I had this problem. libyaml wouldn't compile. It turns out I was missing libtool.
yum install libtool
yum install libyaml (or rvm pkg install libyaml)
rvm reinstall 1.9.3
That solved my problem.
If you have installed ruby on macOS with homebrew, try this solution.
rm -rf /usr/local/lib/ruby/gems/ && brew reinstall ruby
Note that this will get rid of all installed gems. Best save a list of installed gems with gem list before you run this.
$ brew doctor
$ brew link libyaml
I reinstalled ruby 1.9.3 with libyaml support:
rvm reinstall 1.9.3 --with-libyaml
I made sure that I would use 1.9.3 before installing psych:
rvm use 1.9.3
I installed psych:
gem install psych
I got this fixed finally. The issue was that even though I installed libyaml with brew, it was never linked. I had to remove a conflicting header file and then brew link libyaml.
Installing ruby with rvm for mac osx, use autolibs to install libyaml and first uninstalling libyaml helps.
This worked for me:
brew uninstall libyaml
rvm autolibs enable
rvm reinstall ruby-2.1.1
I had the same problem (Lion 10.7.4), and fixed it by upgrading rvm then reinstalling ruby
1) upgrade rvm https://rvm.io//rvm/install/
curl -L https://get.rvm.io | bash -s stable --ruby
2) Then use rvm to reinstall ruby 1.9.3 (which had been previously installed with the earlier version of rvm)
rvm reinstall 1.9.3
sudo port install libyaml # or brew install libyaml
rvm get latest
rvm pkg install iconv
rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p125/
gem install ruby-debug19
rvm reload
reload your .rvmrc (cd out, cd in)
bundle
None of these answers worked for me.
I found my answer on https://github.com/sstephenson/ruby-build/issues/119
I am on Centos 6.3 Virtual Machine.
YOU MUST install libyaml before you install ruby. IF you ALREADY installed ruby you must get rid of the files before compiling source again!!!
# cd to your ruby source location
rm -rf /usr/local/lib/ruby # clean out ruby files
./configure
make && make install
gem -v # check if error is fixed
I built the libyaml files separately from source and installed them in /usr/local/lib. The ruby that RVM created still did not see them, and rather than muck with the makefile or the system LD_LIBRARY_PATH I just copied /usr/local/lib/libyaml* to ~/.rvm/rubies/ruby-1.9.3-p327/lib/
That quieted the warning.
This is what worked for me on Ubuntu:
- installing libyaml-dev (sudo apt-get install libyaml-dev)
- installing rvm + ruby 1.9.3
I tried all of these answers and still wasn't able to get it working. I installed libyaml with homebrew and then installed Ruby 1.9.3 and 2.0.0 with rvm. Each time it complained that I was missing psych (libyaml). But trying to install libyaml told me it was already installed. Rinse, repeat. Urgh.
Finally, what I did was to uninstall libyaml. Then I enabled autolibs in rvm, which (at least in OSX) allows rvm to install and manage dependencies more directly. Now when I installed the Rubies, rvm was able to install libyaml and recognize that it was in the right spot.
So if you've tried all of the other options, try actually removing libyaml and then installing your Rubies. It's count-intuitive from the error messages, but that's what finally worked for me.
I had the same problem (Cent OS 5.7), none of the above solutions worked to me.
// My console warning
/usr/local/rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
After doing several re-installs, I realized it's looking for yaml in ruby version of 1.9.1 instead of 1.9.3. So i downgraded
// obviously after installing `libyaml`
rvm remove all
rvm install 1.9.1
rvm use 1.9.1 --default
And it worked 8D!
On CentOS 6.3 none of the above worked. However installing libyaml from source before installing ruby resolved the problem.
$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
and then
rvm install 1.9.3
gem install rails
I'm using
rvm 1.16.20 (version) by Wayne E. Seguin ,
Michal Papis [https://rvm.io/]
and also got the following error during bundle install
.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `': It seems
your ruby installation is missing psych (for YAML output). To
eliminate this warning, please install libyaml and reinstall your
ruby.
Here are three different ways to resolve this error w/o having to gem install psych
export LD_LIBRARY_PATH=/usr/local/lib
alter /etc/ld.so.conf
sudo su - root
echo /usr/local/lib64 >> /etc/ld.so.conf
echo /usr/local/lib >> /etc/ld.so.conf
ldconfig
Fix rvm ruby 1.9.3 installation via
patch .rvm/scripts/functions/manage/ruby < ruby-1.9.3-LDFLAGS.patch
rvm uninstall ruby-1.9.3-p194
export LDFLAGS='-L /usr/local/lib64 -L/usr/local/lib -Xlinker -R/usr/local/lib64 -Xlinker -R/usr/local/lib'
rvm install ruby-1.9.3-p194 --disable-binary
grep configure_args .rvm/src/ruby-1.9.3-p194/config.log # to confirm LDFLAG
$ diff -c .rvm/{src/rvm/,}scripts/functions/manage/ruby
*** .rvm/src/rvm/scripts/functions/manage/ruby 2012-11-10 06:28:14.000000000 +0000
--- .rvm/scripts/functions/manage/ruby 2013-01-25 17:18:00.000000000 +0000
***************
*** 106,123 ****
# when relative is in effect libyaml is installed in ruby itself so it will be moved with ruby
prefix_path="${rvm_rubies_path}/${rvm_ruby_string}" libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_rubies_path}/${rvm_ruby_string}/include"
! __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib"
if [[ -d "${rvm_rubies_path}/${rvm_ruby_string}/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib64"
fi
else
libyaml_installed || libyaml # Installs libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_path}/usr/include"
! __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib"
if [[ -d "${rvm_path}/usr/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib64"
fi
fi
--- 106,123 ----
# when relative is in effect libyaml is installed in ruby itself so it will be moved with ruby
prefix_path="${rvm_rubies_path}/${rvm_ruby_string}" libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_rubies_path}/${rvm_ruby_string}/include ${CFLAGS}"
! __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib ${LDFLAGS}"
if [[ -d "${rvm_rubies_path}/${rvm_ruby_string}/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_rubies_path}/${rvm_ruby_string}/lib64 ${LDFLAGS}"
fi
else
libyaml_installed || libyaml # Installs libyaml
! __rvm_update_configure_env CFLAGS="-I${rvm_path}/usr/include ${CFLAGS}"
! __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib ${LDFLAGS}"
if [[ -d "${rvm_path}/usr/lib64" ]]
! then __rvm_update_configure_env LDFLAGS="-L${rvm_path}/usr/lib64 ${LDFLAGS}"
fi
fi
I also struggled with the same failures with rvm install ruby-2.0.0 for many, MANY hours. I had tried all the different methods to install libyaml; wget source, yum and rvm. I also tried all of the different approaches listed in similar threads. Because I tried all the different methods, I had multiple installations and locations of libyaml.
RVM is perfectly capable of installing the necessary dependencies in ~/.rvm. Simply removing the libyaml files from non-RVM install fixed this issue for me:
sudo rm /usr/local/lib/libyaml*.*
rvm reinstall ruby-2.0.0-p0
Works!
NON-RVM ruby install method.
% uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
% cat /etc/redhat-release
CentOS release 6.4 (Final)
% wget http://apt.sw.be/redhat/el5/en/x86_64/dag/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
% sudo rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm"
% sudo rpm -ivh rpmforge-release-0.3.6-1.el5.rf.*.rpm"
DISABLE rpmforge by editing this file and set enabled=0
% sudo vi /etc/yum.repos.d/rpmforge.repo
% grep rpmforge ~/.aliases
alias rpmforge "sudo yum --disablerepo='*' --enablerepo='rpmforge'"
% rpmforge install libyaml libyaml-devel
% sudo yum list installed | grep libyaml
libyaml.x86_64 0.1.4-1.el5.rf #rpmforge
libyaml-devel.x86_64 0.1.4-1.el5.rf #rpmforge
The libyaml-devel is the key.
% tar zxvf ruby-1.9.3-p448.tar.gz
% cd ruby-1.9.3-p448
% ./configure -prefix=$HOME/ruby-1.9.3-p448
% make ; make install
% cd $HOME; ln -s ./ruby-1.9.3-p448 ruby
Update your path and source .cshrc
% echo $PATH
/home/francis/ruby/bin:/usr/sbin:/home/francis/bin:/home/francis/jdk1.7.0_25/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin
% which ruby
/home/francis/ruby/bin/ruby
% gem update --system
Set your GEM_HOME in .cshrc and source
% echo $GEM_HOME
% /home/francis/ruby/lib/ruby/gems
% gem install mysql2 pg ruby-debug-ide rails capistrano capistrano-ext passenger
If you are building ruby from source (I built 1.9.3 on Fedora 20), you will need this before you do the configure/make to build ruby:
yum install libyaml-devel
(in addition to yum install libyaml.) Similar to Francis's answer using rpmforge above.
I was having this error and noticed I had different versions of Ruby installed with HomeBrew, along with many gems that I no longer used. So did a full clean up like this:
$ brew remove --force ruby # remove all versions installed
$ sudo rm -rf /usr/local/lib/ruby # remove all gems and leftover files
$ brew install ruby
$ gem install bundler
$ bundle install
If you don't use a Gemfile, make sure you know which gems to reinstall.
In my case all I needed to do was
rm -rf /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4
rm -rf /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4
Now, FWIW, gem list includes
psych (2.2.4, default: 2.2.2)
Ubuntu
Using RVM
Reason: Conflicting Psych gem versions between ruby 2.4.4 and ruby 2.5.1
I spent a few hours trying to get my error to go away and none of the replies here suited my case, so I thought I would post how I solved it...
In my case when I ran gem list | grep psych, I had the following output: psych(default: 3.1.0, default: 3.0.2).
Apparently since version 2.5.0, ruby depends on the newer version of psych (3.1.0) and having both set as default was messing up everything. Notice that I never ended up finding out why those were both set as default - I completely wiped out rvm and ruby versions from my computer due to this.
So in order to remove the older version (3.0.2) from being set as default, head to ~/.rvm/gems/ruby-x.x.x#global/specifications/default. If you run ls | grep psych it will return both versions of the gem here. If you want to maintain 3.1.0 as default just run mv psych-3.0.2.gemspec ../ and then try running gemlist to make sure it is listing only one version as default now...
tl;dr
cd /.rvm/gems/ruby-x.x.x#global/specifications/default
mv psych-3.0.2 ../
Hope this helps someone!
On Snow Leopard, the solution by Catharz did not work for me. This solution, however, did:
brew install libyaml
rvm get head
rvm reinstall 1.9.3 --with-gcc=clang
(The rvm reinstall gave me a warning about clang not having the option "--with-libyaml" but it solved the error message regardless.)
This worked for me at least on Ubuntu 10.04
$ sudo apt-get install libtool
$ rvm reinstall 1.9.3
On Solaris:
# sudo crle -64 -l /usr/local/lib
to add /usr/local/lib to the shared library search path
(see man crle)
When I switch from 64 bit to 32 bit on Snow Leopard 10.6.8, I had reinstalled ruby (used rvm) to run on 32bit and met the same problem. So I just 'cleanup' all thing that cached by rvm before and problems solved. Hope this tip can help someone.
rvm cleanup all
rvm install ruby_version_here //(This way, rvm will also re-download newest yaml).
BTW, if you still meet this problem, I think you can try:
gem install psych
I am getting the following error:
$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Where can i get the file and what directory should it go in?
Thanks!
The readline module is normally part of the Ruby package itself.
Did you manually build your Ruby install? If so, you want to make sure libreadline and its headers are installed, and build again.
On Debian/Ubuntu:
apt-get install libreadline-dev
Or on RHEL/CentOS, try
yum install readline-devel
Update:
You are using a very old release of Ubuntu. If you want to keep using it, open /etc/apt/sources.list in a text editor, and change all occurrences of archive.ubuntu.com to old-releases.ubuntu.com. Then, run apt-get update and try the above again.
I urge you to consider updating your installation, though. Ubuntu 7.10 hasn't seen security updates in quite a while, and using it in production is not recommended. Even if it's not a production machine, there's a good chance you'll run into further problems because of old versions of certain libraries/dependencies.
You need to install the ncurses and readline libraries.
On Ubunutu you could do
sudo apt-get install libreadline5-dev libncurses5-dev
and then you will have to recompile readline which comes with your ruby source
cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
If you are using RVM you could simply do
rvm package install readline
EDIT:
On newer RVM versions, this last command is
rvm pkg install readline
Add the following line to your Gemfile and run bundle update
gem 'rb-readline'
credits to similar question/answer at install ruby 1.9.3 using rvm on ubuntu
This easiest way to get relief from this problem,
just add to your Gemfile:
gem 'rb-readline'
And then run bundle install
Run the command
rvm requirements
It shows the requirements and dependencies. Install those and reinstall the ruby on rvm
rvm remove 1.9.2
rvm install 1.9.2
It works!
EDIT
If you can't find the requirements option update your rvm.
rvm update --head # older rvm
or use rvm upgrade
Maybe this is a bullshit answer, but I ran into this problem today after upgrading postgres from 9.5.3 to 9.6, along with which homebrew upgraded readline from 6.something to 7. I ended up rolling back my postgres to 9.5.3 and that resolved the issue.
I've just moved over to Ubuntu 8.10 as my dev box; it's my first serious foray into Linux as a daily-use OS, and I'm having a hard time getting Rails going. I have followed a number of tutorials which all seem to work fine, but when I try and use gem install or gem update on anything, I get an error that looks like this:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:5
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:167:in `load_and_instantiate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:88:in `[]'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:144:in `find_command'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:131:in `process_args'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:102:in `run'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
from /usr/local/bin/gem:21
I have (as recommended in the tutorials) installed zlib, zlib1g, and zlib1g-dev. I've even found a few tutorials on this particular problem (all for flavors other than mine, however) but they didn't help.
I'm on Ubuntu 8.10, ruby version 1.8.8dev gem version 1.3.2
I've tried reinstalling ruby and gems each and separately, to no avail.
If you come across this question trying to install Ruby using Ruby Version Manager (RVM) on Ubuntu 10.04 then there are instructions on installing zlib on the rvm web site http://rvm.beginrescueend.com/packages/zlib/
The steps are:
rvm pkg install zlib
(or
rvm package install zlib if you get "ERROR: Unrecognized command line argument: 'pkg'" - older versions of rvm used the verb 'package' instead)
then
rvm remove 1.9.1
rvm install 1.9.1
I am using Ubuntu 10.04 (Lucid), i wanted to install ruby 1.9.2 because 1.9.1 is not recommended with Rails. So I downloaded the source for 1.9.2 and unzipped/unarchived it. my source distro is ruby-1.9.2-p0. After I unpacked it, I built zlib as follows:
cd ruby-1.9.2-p0/ext/zlib
ruby extconf.rb
make
sudo make install
sudo gem install rails
that fixed the problem. This is similar to what other people posted above, but not exactly, so I figured I may as well post exactly what I did to get it going.
I have the same problem in CentOS and fix it by executing the following command:
First, I ensure that zlib and zlib-devel exist (like many suggested above).
yum install zlib zlib-devel
Second, I recompiled and installed the sources of zlib that comes with ruby.
cd /home/myname/installers/ruby-1.8.7-p174/ext/zlib/
ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
make
make install
That commands seem to fix the problem, then I execute gem update --system and the error with zlib vanished. Then I install rails with gem install rails. Note to mention I had installed gem before, and after recompile and install zlib, I don't recompile neither install gem (actually I don't knew how uninstall it because I don't found a script to do that)
That works for me...hope to you to.
Regards.
try
aptitude install zlib1g-dev
Then go about your business.
I really didn't like any of these answers ... none really focused on the users actual needs and question ... just people telling what they did ... no context and it didn't even work for me ...
So, ..
I'm installing a new box Ubuntu 8.04 LTS 64-bit ...
So, I ...
cd ~
wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p180.tar.gz
tar -xvvf ruby-1.9.2-p180.tar.gz
cd ruby-*
./configure
make
install
sudo make install
And then I have this problem with ...
gem list
it doesn't work ... something about zLib not found crap ...
So, I actually READ the README and find that I need to edit a file ...
[my ruby source directory]/ext/Setup
and UN-COMMENT the line with zLib in it ... by removing the "#" in the first column
Then I run the commands again ... included here for reference ...
./configure
make
install
sudo make install
and all is well ... it's logical ... and is devoid of "rvm" and other ... "just install more stuff to make it work" type solutions.
Joet
Just goto Ruby Source Package , Unzip it.
Goto /your-ruby-dir/ext/zlib
ruby extconf.rb
make
sudo make install
If the packages are missing it will tell you, mainly libzlib related packages
Regards
Saurabh
rvm package install zlib
rvm remove 1.9.1
rvm install 1.9.1
That did it. After numerous wild goose chases, I'm glad I found this page.
yes, and that didn't do the job either. Got this from another source, this finally did it for me where the other stuff failed.
wget http://www.blue.sky.or.jp/atelier/ruby/ruby-zlib-0.6.0.tar.gz
tar xvzf ruby-zlib-0.6.0.tar.gz
cd ruby-zlib-0.6.0
ruby extconf.rb && make
sudo make install
Reinstall ruby gems from source
Thanks anyway, guys.
The problem is that Ruby on Ubuntu isn't built against zlib; you'll want to do a source build to install Ruby. You can do this with apt-get source -b ruby
Did you try apt-get install libzlib-ruby?
Also install rubygems from rubyforge. I don't like the rubygems package in Ubuntu.
On Debian (Squeeze):
libruby contains zlib for ruby amongst all the other stuff you'll need to make ruby work properly on Debian. So...
apt-get install libruby
Then...
cd /usr/local/src/ruby
make clean
make
make install
cd ../rubygems
ruby setup.rb
gem install rails
This made it work for me, but your mileage may vary. I did to a slight shotgun approach to zlib before finding that everything needed was covered by libruby.
You could try to download the ruby enterprise deb package on the phusion site. And install passenger through the package. Follow the instructions here.
Or you could try the bash script found here.
When running Rails I would not recommend using Ruby 1.8.8dev. Stick with 1.8.6, preferably the Ruby Enterprise Edition. See this post on RailsLab what other people are using.
If you insist on going hi-tech, install Ruby 1.9.1.
But in both cases build it yourself or use Marans suggestion.