Cannot execute "rails console" due to an error with readline - ruby-on-rails

I cannot execute rails console due to this error:
localhost:TwitterForZombies wiz$ rails c
/Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/irb/completion.rb:9:in `require': dlopen(/Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin12.2.1/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.2.dylib (LoadError)
Referenced from: /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin12.2.1/readline.bundle
Reason: image not found - /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin12.2.1/readline.bundle
from /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:3:in `require'
from /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:38:in `require'
from /Users/wiz/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:38:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed readline via homebrew.
I'd like to keep using rbenv instead of rvm.
Thank you for reading my question.

I had the same issue recently with homebrew and libreadline.7.x.dylib / libreadline.6.x.dylib
I solved it by running:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
source: https://github.com/rails/rails/issues/26658

Homebrew is great, but once in a while it doesn't play nice with some of the other moving parts.
A brew update && brew upgrade brought in libreadline.7.x.dylib while automatically removing libreadline.6.x.dylib, which ruby was still relying on.
There may be more clever ways to fix the problem, but brute force worked for me:
$ rbenv uninstall 2.3.1
$ rbenv install 2.3.1
$ cd /path/to/my/app
$ bundle
The above assumes the presence of rbenv's ruby-build and, of course, bundler; replace 2.3.1 with whatever version of ruby you are using.
Please note that similar problems can occur with different homebrew-managed libraries (see my own answer to this, for example)

I'm on OSX, ruby2.3.0, rails5. Adding gem 'rb-readline' to my Gemfile fixed this problem.

I got the same error with Ruby 2.1.0, and rails 4.0. After searching and trying a lot, finally it work well:) Here are what I did:
rvm cleanup all
rvm autolibs enable
rvm install 2.1.0
The other ways:
brew update
brew uninstall readline
brew install readline
The autolibs command will force RVM install all dependencies, so you don't need to worry about it.
Hope it's helpful.

As Sachin hinted, installing readline and then reinstalling ruby is the ideal approach - but the details are a bit different for rbenv. Given your file paths, I'm guessing you're on a Mac, so the following should help:
brew install readline ruby-build
env CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 1.9.3-p286
This was taken from the ruby-build Wiki and a quick google search.

Using mac, El Captain version, it is possible to fix just by doing
rvm reinstall your_ruby_version
(like rvm reinstall ruby-2.3.1)
Hope this helps, good luck!

taken from github user #enderahmetyurt (this is the only solution that worked for me).
Solution: Add gem 'rb-readline' to your Gemfile in development group and bundle install. It's the easiest solution for silly "readline" errors.

try installing readline, and reinstall your ruby
https://rvm.io/packages/readline/

Related

Unable to Execute Rails console command Ruby

/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `require': dlopen(/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This is my error screen after trying to execute the command. I've tried to uninstall and reinstall readline and that did not help. I am just learning rails and do not 100% know what I am doing (just following a guide) so this type of error is past my understanding. Thanks!
Might not be related, but I had the same thing happen to me today.
I had a fully-functioning Ruby 2.3.1 working fine this morning. In my case, Ruby was compiled and installed by ruby-build and managed by rbenv.
At one point today I updated Homebrew with
brew cleanup --prune=30
brew update
brew upgrade
One of the formulae upgraded was readline 7.0:
$ brew info readline
...
/usr/local/Cellar/readline/7.0 (45 files, 2M)
Poured from bottle on 2016-10-05 at 08:09:22
Shortly afterwords I found that my readline support for Ruby had become completely broken. I saw errors just like yours:
/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `require': dlopen(/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `lazy_readline'
The solution was to completely delete my Ruby installation and recompile it:
rm -rf ~/.rbenv/versions/2.3.1
rbenv install 2.3.1
I know you are using rvm and not rbenv, but perhaps the solution in your case is similar: delete your Ruby installation and re-install it using rvm.
A really fast and quick solution is to add rb-readline to your Gemfile.
(In case the other solutions don't work and you want to move on until you have time to address the issue. I know it this is not ideal but it is a working solution.)
In the GemFile:
group :development do
gem 'rb-readline'
end
Now, just bundle install. I found this solution on Option 4 at
(https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X)
I hope it helps.
There's something wrong with your rvm, it doesn't seems to be related with rails. Please verify if it's installed properly.
Ensure that you've checked the rvm prerequisites on https://rvm.io/rvm/prerequisites
and that your install is working properly, e.g.
(from: https://rvm.io/rvm/install)
If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output rvm is a function as shown below.
$ type rvm | head -n 1
rvm is a function
Check on your mac if readline has been properly compiled, or try to do a clean install ruby-2.3.0 again
You can check on RVM regarding the package and autolibs on: https://rvm.io/packages/readline
I had similar issue. My Ruby was installed using HomeBrew. In my case I needed to uninstall Ruby; install/link libyaml; and then reinstall ruby.
brew uninstall ruby
brew link libyaml
brew install ruby
Same thing happened to me when I unwittingly ran rvm requirements after installing ruby 2.3.1.
rvm uninstall 2.3.1
rvm install 2.3.1
Above fixed it.
Running this from the command line worked for me:
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
from github

Installing Ruby on Rails on Mac

To install RoR on my Mac (v10.9.2), I decided to follow the instructions for Ruby 1.9.2 here: https://stackoverflow.com/a/8464619/2278546
"rvm install 1.9.2" was taking too long, so based on suggestions on SO, I used "rvm requirements" to install each of the requirements individually with macports. I then executed "rvm install 1.9.2" and it ran much faster.
When I tried to execute "gem install rail", I got an error message saying
activesupport requires Ruby version >= 1.9.3
As a result, I went back and tried again with 1.9.3:
rvm install 1.9.3
rvm --default 1.9.3
gem update
gem install rails
This time, during the rails install command, the process got stuck installing the documentation for rails. I decided to interrupt and run this instead:
gem install --no-ri --no-rdoc rails
This worked! I ran the following:
rails new pong; cd pong; rails generate controller welcome index
The last command in that string gave me the following error:
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/sid.rb:17:in
fiddle_func': uninitialized constant Spring::SID::DL (NameError)
from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/sid.rb:30:in
sid' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/sid.rb:39:in
pgid' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/server.rb:78:in
set_pgid' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/server.rb:34:in
boot' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/server.rb:14:in
boot' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/run.rb:36:in
block in boot_server' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/run.rb:34:in
fork' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/run.rb:34:in
boot_server' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/run.rb:18:in
call' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/command.rb:7:in
call' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/rails.rb:23:in
call' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client/command.rb:7:in
call' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/client.rb:26:in
run' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/bin/spring:48:in
<top (required)>' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/binstub.rb:11:in
load' from
/Users/me/.rvm/gems/ruby-1.9.3-p545/gems/spring-1.1.2/lib/spring/binstub.rb:11:in
<top (required)>' from /Users/me/Coding/pong/bin/spring:16:in
require' from /Users/me/Coding/pong/bin/spring:16:in <top
(required)>' from bin/rails:3:inload' from bin/rails:3:in `'
Based on suggestions read here and here and elsewhere, I decided to try with a different compiler:
port install gcc46
CC=`which gcc-mp-4.6`
rvm reinstall 1.9.3
gem install
rvm reinstall 1.9.3
Same problem with this installation as well.
I suspect interrupting those builds might have left things in a bad state. First off, uninstall 1.9.2. 1.9.3-p545 is the oldest supported version, as of now at least.
Next, uninstall the gem 'spring-commands-rspec' and run a gem pristine -all. Then do another bundle install. FWIW, I am able to run spring on my 10.9.2 macbook. You may have to reinstall the xcode command line tools if your gcc is giving you issues.
Beyond all that, you don't need spring to run a rails app. It's primarily a helper during development and testing. Once you get things cleaned up, I would just remove the thing from your Gemfile until you actually need it.
I was able to get things running by mixing #Andrew's advice with some common sense...
I first cleaned up the mess I had made:
sudo rvm remove 1.9.2
sudo rvm remove 1.9.3
sudo rvm remove 1.9.3-p545
sudo gem uninstall spring-commands-rspec
sudo gem pristine -a
sudo port uninstall rvm
I then reinstalled rvm
sudo port install rvm
and reinstalled Ruby 1.9.3 with rails:
sudo rvm install 1.9.3
sudo gem update
sudo gem install --no-ri --no-rdoc rails
The problem as described above still occurred.
I then remembered that I had received the following message when installing Ruby (confirming Andrew's comment):
WARNING: Please be aware that you just installed a ruby that is no
longer maintained (2014-02-23), for a list of maintained rubies visit:
http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
Please consider upgrading to ruby-2.1.1 which will have all of the
latest security patches.
So, I cleaned up again:
sudo rvm remove 1.9.3
sudo rvm remove 1.9.3-p545
sudo gem uninstall spring-commands-rspec
sudo gem pristine -a
Then, I tried installing Ruby 2.1.1 and Rails:
sudo rvm install 2.1.1
sudo gem update
sudo gem install --no-ri --no-rdoc rails
This time, I got no errors when I tried to run
rails new pong; cd pong; rails generate controller welcome index
This is not an ideal answer because I still couldn't get 1.9.3 to work, but it fits my purposes (I think). Anyone have any theories explaining why 1.9.3 doesn't work?
Thanks,
Grasswistle

'security policies' error when trying to run bundle install

I have recently been having a lot of trouble with my rubies.
Now whenever I try and run bundle install on my projects I get the following error:
bundle install
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler- 1.3.5/lib/bundler/rubygems_integration.rb:172:in `security_policies': uninitialized constant Gem::Security::Policies (NameError)
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:175:in `<class:CLI>'
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:6:in `<module:Bundler>'
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:5:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:18:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
I have tried reinstalling rubies, I have tried rvm get head and gem update --system
I have also tried uninstalling and re-installing OpenSSL, through rvm package and brew install.
And I have tried completely imploding RVM and starting again, but none of this seems to work. This seemed to happen after I shifted to Mavericks.
Does anybody out there have an idea what might be happening? I have been at this for 3 days...
Edit:
I am having the same issue with all these rubies:
1.9.3
2.0.0-p195
2.0.0-p247
2.1.0-preview1
Assuming you're using brew...
Run brew doctor to check the current state and perform any steps it recommends.
Run rvm list and note which versions of ruby are installed. Remove the offending ruby version with rvm remove 2.0.x where 'x' is the minor revision you are working with, or run rvm remove 2.0 to remove them all.
Now upgrade to the latest rvm, rvm get stable.
Let rvm install dependencies automatically by running rvm autolibs enable. This will allow rvm to install whatever it needs during the ruby installation, including openssl. It will use brew, as I am assuming here, but will also use fink or macports if they are installed instead. In the past I have had problems with brew and macports both installed.
Install the latest ruby via rvm, rvm install 2.0.
Bundler should now work.
When running bundle install on a new rvm gemset running Ruby 2.0 and Rails 4.0 on OSX Mavericks, I was receiving the same error:
gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:172:in `security_policies': uninitialized constant Gem::Security::Policies (NameError)
Running 'brew install openssl', then 'rvm reinstall 2.0' worked for me.
Have you tried using the --trust-policy=[] option with bundle install?
To Apply the Rubygems security policy named policy, where policy is one of HighSecurity, MediumSecurity, LowSecurity, or NoSecurity.
More - http://bundler.io/v1.3/man/bundle-install.1.html

Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib

I'm getting this error when trying to run rspec in Hartl's tutorial. I googled the error, but it's never for the specific version and the fixes don't actually fix my problem.
/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `require': dlopen(/Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/Jimbo/.bundler/tmp/22862/gems/nokogiri-1.6.0/ports/i686-apple- darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri- 1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri.rb:28:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.1.0/lib/capybara.rb:2:in `<top (required)>'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/Jimbo/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
I suggest you first uninstall Nokogiri using:
sudo gem uninstall nokogiri
Then install Nokogiri using rubygems:
gem install nokogiri
If that doesn't work, there's an open issue on Nokogiri to support libxml 2.9.0 and later. There's a libxml2-2.9.1 branch that was started in preparation for the next release of libxml2.
Then try pulling from that branch in your Gemfile like this:
gem "nokogiri", github: "sparklemotion/nokogiri", branch: "libxml2-2.9.1"
or install an older version of libxml2.
If that still doesn't work you may also want to try the suggestions here: What to do if libxml2 is being a jerk.
Not sure if it helps anyone, but I could just get nokogiri installed by using system libs
gem install nokogiri -- --use-system-libraries
If you have Homebrew installed, try this. It solves the issue with the "Parsing documentation for nokogiri-1.6.1" hang. This worked for me.
gem uninstall nokogiri libxml-ruby
It'll ask you a series of questions based on how much of it you want to uninstall, answer "yes" or "[y]" to all.
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link --force libxml2
brew install libxslt
brew link --force libxslt
gem install nokogiri --no-rdoc --no-ri
Then, in your project file:
bundle install
Your error message says:
nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib
provides version 10.0.0
This makes me think that your gem actually requires a version of libxml that is newer than your system version. How have you installed libxml2? If you have homebrew installed, you might want to try upgrading it with
brew update
brew upgrade
I was able to install Nokogiri 1.6.0 with Ruby 2.0.0p247 on OS X 10.9, and then require it in IRb. I double checked with Homebrew, and it is actually keg-only. However, Nokogiri seems to install its own version into gems/nokogiri-1.6.0/ports. On my machine, it is under x86_64-apple-darwin13.0.0.
First gem uninstall nokogiri
Second install nokogiri
third restart terminal
be happy
Try the following inside your project directory.
gem uninstall nokogiri
If there are more than one versions installed, a prompt will appear asking which version to remove. use the last option that reads "All versions".
Next, run bundle install inside your project directory. once it finishes installing the needed gems you should be good to go.
In my case, I hit the last option "All versions" as it doesn't hurt my project but it is possible that you might need the other versions based on different projects.
First, check your version of libxml:
otool -L /usr/lib/libxml2.2.dylib
It can return
/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 11.0.0, current version 11.0.0)
or
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
Then you can try reinstalling libxml to upgrade it:
brew uninstall libxml2 libxslt
brew install libxml2 libxslt
After that, try to recompile your package:
make clean
./configure
make
sudo make install
Reinstalling the gem didn't work for me, nor did pulling the particular branch.
It's not ideal, but I found that rolling back to 1.5.9 solved the issue.
Nokogiri generally uses system libraries. So, your ruby has it installed already just make sure that you've run below command before start bundle install.
rvm use ruby-2.2.4 (your current ruby-version)
Sometimes, you also need to run first
/bin/bash --login
rvm use ruby-2.2.4
Note: Only if you're using rvm

Ubuntu rails install fails on zlib

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.

Resources