rmagick preventing rails server from working - ruby-on-rails

I have to use rmagick, and it is not allowing me to start the rails server. I have read around on here and Google, none of the solutions have help so far. There is something going wrong with the Library and I'm not sure how to fix it.
If anyone has advice with fixing this exact problem that would be much appreciated.
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `require': dlopen(/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/rmagick-2.13.2/lib/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libltdl.7.dylib (LoadError)
Referenced from: /usr/local/lib/libMagickCore-Q16.7.dylib
Reason: image not found - /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/rmagick-2.13.2/lib/RMagick2.bundle
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `<top (required)>'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `require'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in `each'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in `block in require'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in `each'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in `require'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.0/lib/bundler.rb:132:in `require'
from /Users/lexi87/dating/config/application.rb:7:in `<top (required)>'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.12/lib/rails/commands.rb:53:in `require'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.12/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I was able to fix this error, so this should work for anyone else if they're having the same exact problem.
Here are the steps to fixing:
brew uninstall imagemagick
gem uninstall rmagick
sudo gem install json # (not sure this step is needed)
sudo apt-get install libmagick9-dev
bundle install
And then it work perfect. Now I can launch rails server and I receive no more errors. Hope this helps someone!

You just need reinstall rmagick with your current imagemagick
gem install rmagick
In someother issues i found the following fixed the issue by using,
gem pristine rmagick

I had several problems with my install, what worked for me was
brew uninstall imagemagick
gem uninstall rmagick
brew install imagemagick
bundle install
brew unlink libtool
brew link libtool
without the first I was getting errors trying to install rmagick and without the last two there were errors starting the rails server

I was also having this issue. I had tried a lot of different tricks, and oddly enough what worked was this oddness. The first 2 commands seem useless, but considering I don't know how this worked, I'm leaving them in, too.
Don't ask questions, just run them and embrace the rmagick
brew install libtool --universal
brew link libtool
brew unlink libtool && brew link libtool
gem uninstall rmagick
gem install rmagick

Related

Cocoa pods install inside user directory(without sudo)

I can only access my directory, so I want to install the cocoa pods to the users directory. How can I achieve this?
I follow the below link but is not working.
Sudo-less installation
Please assist me how to achieve this.
I'll be very thankful if any one provide me step by step procedure to achieve this.
What I tried
gem install cocoapods --user-install
Error I'm getting
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:959:in `read': Permission denied - /Library/Ruby/Gems/2.0.0/specifications/terminal-notifier-1.6.0.gemspec (Errno::EACCES)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:959:in `load'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:644:in `block (2 levels) in each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:643:in `block in each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:642:in `each_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:658:in `each_normal'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:669:in `_all'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb:822:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:431:in `map'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:431:in `find_files'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems.rb:942:in `load_plugins'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/gem_runner.rb:73:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/bin/gem:9:in `<main>'
Thanks in advance
I'm posting the steps which worked form me (In case any one need this).
I used Homebrew and bundler
Install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install brew-gem:
brew install brew-gem
Install bundler:
brew gem install bundler
bundler is a package management tool which provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.
Then add cocoapod in gemfile (if gemfile is missing then, use bundle init to create gemfile).
Then naviaged to your project directory and execute following command
bundle install --path vendor
The above command will look the gemfile and install the all the gems in the vendor directory.
Now onward prefix the bundle exe to add the cocoapod commands.
i.e
bundle exec pod install
bundle exec pod update

Error installing ruby-1.9.3-p547 with RVM on osx 10.9.3

How can I get around this error:
$ rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.9/x86_64/ruby-1.9.3-p547.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Warning: DYLD_LIBRARY_PATH environment variable is set, this might interact with the compilation and ruby.
Installing Ruby from source to: /Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p547, this may take a while depending on your cpu(s)...
ruby-1.9.3-p547 - #downloading ruby-1.9.3-p547, this may take a while depending on your connection...
ruby-1.9.3-p547 - #extracting ruby-1.9.3-p547 to /Users/TomCaflisch/.rvm/src/ruby-1.9.3-p547...
ruby-1.9.3-p547 - #applying patch /Users/TomCaflisch/.rvm/patches/ruby/GH-488.patch.
ruby-1.9.3-p547 - #configuring.
Error running './configure --prefix=/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p547 --with-opt-dir=/usr/local/Cellar/libyaml/0.1.4:/usr/local/Cellar/readline/6.2.4:/usr/local/Cellar/libksba/1.3.0:/usr/local/Cellar/openssl/1.0.1e --without-tcl --without-tk --disable-install-doc --enable-shared',
showing last 15 lines of /Users/TomCaflisch/.rvm/log/1404187306_ruby-1.9.3-p547/configure.log
[2014-06-30 23:01:50] ./configure
current path: /Users/TomCaflisch/.rvm/src/ruby-1.9.3-p547
GEM_HOME=/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327
PATH=/Users/TomCaflisch/.rvm/usr/bin:/usr/local/Cellar/pkg-config/0.28/bin:/usr/local/Cellar/libtool/2.4.2/bin:/usr/local/Cellar/automake/1.14/bin:/usr/local/Cellar/autoconf/2.69/bin:/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327/bin:/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#global/bin:/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p327/bin:/Users/TomCaflisch/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin
GEM_PATH=/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327:/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#global
command(7): ./configure --prefix=/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p547 --with-opt-dir=/usr/local/Cellar/libyaml/0.1.4:/usr/local/Cellar/readline/6.2.4:/usr/local/Cellar/libksba/1.3.0:/usr/local/Cellar/openssl/1.0.1e --without-tcl --without-tk --disable-install-doc --enable-shared
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.2.0
checking host system type... x86_64-apple-darwin13.2.0
checking target system type... x86_64-apple-darwin13.2.0
checking whether the C compiler works... no
configure: error: in `/Users/TomCaflisch/.rvm/src/ruby-1.9.3-p547':
configure: error: C compiler cannot create executables
See `config.log' for more details
There has been an error while running configure. Halting the installation.
I'm rocking osx 10.9.4 at the moment.
When i do $ rvm get latest, I get this error:
$ rvm get latest
Downloading https://get.rvm.io
Downloading https://github.com/wayneeseguin/rvm/archive/1.25.28.tar.gz
Upgrading the RVM installation in /Users/TomCaflisch/.rvm/
RVM PATH line found in /Users/TomCaflisch/.bashrc /Users/TomCaflisch/.zshrc.
RVM sourcing line found in /Users/TomCaflisch/.bash_profile /Users/TomCaflisch/.zprofile.
Installing gem-wrappers gem in 4 gemsetsError running 'gem install gem-wrappers -v >=1.2.4 --no-ri --no-rdoc',
showing last 15 lines of /Users/TomCaflisch/.rvm/log/1405391557_ruby-1.9.3-p484/gem.install.gem-wrappers->=1.2.4.log
PATH=/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p484#global/bin:/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/bin:/Users/TomCaflisch/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin
GEM_PATH=/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p484#global
command(7): gem install gem-wrappers -v >=1.2.4 --no-ri --no-rdoc
Error loading RubyGems plugin "/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p484#global/gems/executable-hooks-1.2.6/lib/rubygems_plugin.rb": dlopen(/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle
Reason: image not found - /Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle (LoadError)
/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/yaml.rb:84: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.
ERROR: Loading command: install (LoadError)
dlopen(/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle
Reason: image not found - /Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-darwin12.5.0/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Error running 'gem install gem-wrappers -v >=1.2.4 --no-ri --no-rdoc',
showing last 15 lines of /Users/TomCaflisch/.rvm/log/1405391559_ruby-2.0.0-p247/gem.install.gem-wrappers->=1.2.4.log
Reason: image not found - /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin12.4.0/psych.bundle
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:1:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/yaml.rb:5:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:659:in `load_yaml'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:327:in `load_file'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:196:in `initialize'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:74:in `new'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:39:in `run'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.0.0-p247/bin/gem:21:in `<main>'
Error running 'gem install gem-wrappers -v >=1.2.4 --no-ri --no-rdoc',
showing last 15 lines of /Users/TomCaflisch/.rvm/log/1405391560_ruby-2.1.0-preview1/gem.install.gem-wrappers->=1.2.4.log
Reason: image not found - /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/x86_64-darwin12.5.0/psych.bundle
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/psych.rb:1:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/yaml.rb:5:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems.rb:659:in `load_yaml'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/config_file.rb:326:in `load_file'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/config_file.rb:195:in `initialize'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/lib/ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview1/bin/gem:21:in `<main>'
Error running 'gem install gem-wrappers -v >=1.2.4 --no-ri --no-rdoc',
showing last 15 lines of /Users/TomCaflisch/.rvm/log/1405391560_ruby-2.1.0-preview2/gem.install.gem-wrappers->=1.2.4.log
Reason: image not found - /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/x86_64-darwin12.0/psych.bundle
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/psych.rb:1:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/yaml.rb:5:in `<top (required)>'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems.rb:659:in `load_yaml'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:327:in `load_file'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:196:in `initialize'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/TomCaflisch/.rvm/rubies/ruby-2.1.0-preview2/bin/gem:21:in `<main>'
.
Upgrade of RVM in /Users/TomCaflisch/.rvm/ is complete.
# Tom Caflisch,
#
# Thank you for using RVM!
# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: http://rvm.io/help and https://twitter.com/rvm_io
Upgrade Notes:
* No new notes to display.
RVM reloaded!
Was running in to the same issue. Just ran these commands sorted everything out...
$ xcode-select --install - this seems to be the key.
$ rvm cleanup all - may need to run sudo on this one.
$ rvm get latest
$ rvm install ruby-1.9.3- with whatever patch.
Hope this works for you!
Looks like you're missing the Xcode command line tools.
Try running
xcode-select --install
then run
gcc --version
to see if GCC or LLVM is installed. If it is, you can try installing ruby through RVM again.
I had the same issue. For me this solved the problem:
Launch Xcode. When it launched for me it asked permission to finish downloading and installing a few things (sorry I don't recall the exact message or if it even listed the items). I agreed and waited for it to finish download/installation.
I tried rvm install 1.9.3 again and it worked. rvm get latest also now works without issue.

Ruby 2.1.1 with RVM: Getting libyaml errors

I would like to use Ruby 2.1.1p76 and Rails 4.1.0beta1. I am getting some errors with RVM. I was using Ruby 2.0.0 and Rails 4.0.0. I upgraded to OS X Mavericks 10.9.2 and needed to reload everything.
Anyway, these are the commands I am running.
\curl -sSL https://get.rvm.io | bash -s stable --ruby
This installs successfully. Then I run this command to install rails.
sudo gem install rails
I get the following errors, says it is looking for libyaml.
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:4: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.
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle, 9): Library not loaded: /usr/local/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
Reason: image not found - /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/psych.bundle
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:1:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:5:in `<top (required)>'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:616:in `load_yaml'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/username/.rvm/rubies/ruby-2.1.1/bin/gem:21:in `<main>'
So, I run this command which is deprecated.
rvm pkg install libyaml
This gives me a deprecation warning and says to check out autolibs.
So I correct and verify both.
brew install libyaml
##
Warning: libyaml-0.1.4 already installed
more...
brew info libyaml
##
libyaml: stable 0.1.5 (bottled)
http://pyyaml.org/wiki/LibYAML
/usr/local/Cellar/libyaml/0.1.4 (7 files, 344K) *
Built from source
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/libyaml.rb
==> Options
--universal
Install autolibs.
rvm get stable --autolibs=enable
rvm install ruby
rvm --default use ruby-2.1.1
Then, I get the same error.
Using /Users/username/.rvm/gems/ruby-2.1.1
/Users/username/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/yaml.rb:4: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.
brew unlink libyaml && brew link libyaml
https://github.com/wayneeseguin/rvm/issues/2689

Gem libxml-ruby (1.1.4) installs but fails on runtime

I'm trying to run one quite old Rails application on Mavericks where one of the requirements are:
- Ruby ree-1.8.7-2009.10
- Rails 3.0.0
- libxml-ruby 1.1.4 (that's the latest version compatible with the rest of the gems.
I have latest libxml2 package installed. It's version from Homebrew (2.9.1).
To install this gem I used following command:
$ CC=gcc-4.2 gem install libxml-ruby -v '1.1.4'
Output suggested success:
Building native extensions. This could take a while...
Successfully installed libxml-ruby-1.1.4
1 gem installed
though when I try run some rake task, i.e. creating database
bundle exec rake db:create
I get following error:
$ bundle exec rake db:create [ree-1.8.7-2009.10#mygemset]
rake aborted!
dlsym(0x7ffa2d83bbe0, Init_libxml_ruby): symbol not found - /Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/libxml-ruby-1.1.4/lib/libxml.rb:9
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/sso/sso.rb:3
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require'
/Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/restful_sso_authentication.rb:2
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
/Users/myuser/.rvm/gems/ree-1.8.7-2009.10#global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
/Users/myuser/Developer/my-project/config/application.rb:5
/Users/myuser/Developer/my-project/Rakefile:6:in `require'
/Users/myuser/Developer/my-project/Rakefile:6
(See full trace by running task with --trace)
I have tried numerous approaches that can be found on Internet (the most relevant examples concerned problems with installing Nokogiri and similar errors where listed) and none of them worked.
Here is my way to install Rubies on variety of Mac OSes for long long time. For me, there were any no problems with any library or gem. For example more complex Nokogiri gem builds and works like a charm.
Check XCode version
xcodebuild -version
xcode-select --install
Install Homebrew as per it's documentation
Install prerequisites
brew doctor; # Just do what it wants!
brew update;
brew upgrade; # Watch out! for existing bottles
brew install libtool libxml2 libxslt openssl sqlite libyaml;
brew install autoconf automake apple-gcc42;
brew cleanup; # Watch out! for existing bottles
brew tap homebrew/dupes; # Watch out! for existing bottles
Install RVM
curl -L https://get.rvm.io | bash -s stable # Latest stable
rvm get latest
rvm reload # :)
rvm autolibs enable
rvm requirements
Install Ruby
rvm install 2.1 --disable-binary
Probably a previous version break the native loading or your libxml2 is too recent and don't fit the gem implementation.
first uninstall all previous gems (gemset, system)
then reinstall the gem
https://gist.github.com/unixcharles/1226596 ?

Getting nokogiri to use a newer version of libxml2

I've been trying to get Nokogiri installed on my computer (Mountain Lion) to use with rspec and capybara, but for the life of me, I can't get it to run properly.
From what I can tell, the issue is with nokogiri using the wrong version of libxml2. I've so far tried uninstalling and reinstalling libxml2 using Homebrew (making sure it's the most recent one), uninstalling and reinstalling nokogiri using bundle, and specifying the exact path to the libxml2 files that Homebrew installed when installing the nokogiri gem. My most recent install instructions looked like this
sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
where all of those locations do correctly correspond to the locations where the tools are installed. However, upon running bundle exec rspec spec/requests/static_pages.rb, I still get this output:
/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `require': dlopen(/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `<top (required)>'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286#global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
from /Users/alex/Sites/harbingernews/config/application.rb:7:in `<top (required)>'
from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `require'
from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `<top (required)>'
from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `require'
from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `require'
from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'
I've tried all the steps that I've found online (most reference building and loading different versions of libxml2, like this one, but have had no success yet. My Gemfile and Gemfile.lock can be found here. If anyone can help me out at all, I would really appreciate it. I haven't been able to find any other cases online with this problem.
In Mavericks, installing the libraries with brew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before installing the gem did the trick for me.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
This helps me to update libxml and install nokogiri correctly...
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
brew link --force libxml2
brew install libxslt
brew link --force libxslt
bundle config build.nokogiri -- --with-xml2-dir=/usr
--with-xslt-dir=/opt/local --with-iconv-dir=/opt/local
bundle install
Here is the source: http://www.kormoc.com/2013/12/22/nokogiri-libxml2/
Hope this helps somebody...
Just to make it clear, Phrogz's comment helped me out quite a bit. I followed the instructions that he linked to, the What to do if libxml2 is being a jerk? page on Nokogiri's Github page. I ended up using Macports instead of Homebrew, and I'm not sure if that's what made the difference (I had tried many of those steps already) but one way or another, it seems to be working alright now.
Googled this question after upgrading OsX when I had problem:
require': dlopen(/Users/tomi/.rvm/gems/ruby-2.1.1#my-gemset/extensions/x86_64-darwin-12/2.1.0-static/nokogiri-1.5.10/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib (LoadError)
and this worked for me
brew uninstall libxml2 libxslt libiconv
brew install libxml2 libxslt libiconv

Resources