Getting nokogiri to use a newer version of libxml2 - ruby-on-rails

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

Related

How to install and run ffi on M1 Mac

I'm using 'ffi', '~> 1.9',
I'm getting this error when I try to run my rails project
rake aborted!
LoadError: dlopen(/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): tried: '/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))) - /Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle
/Users/kanye.west/dev/anenta/config/application.rb:14:in `<top (required)>'
/Users/kanye.west/dev/anenta/Rakefile:5:in `require'
/Users/kanye.west/dev/anenta/Rakefile:5:in `<top (required)>'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `<main>'
Caused by:
LoadError: cannot load such file -- 2.6/ffi_c
/Users/kanye.west/dev/anenta/config/application.rb:14:in `<top (required)>'
/Users/kanye.west/dev/anenta/Rakefile:5:in `require'
/Users/kanye.west/dev/anenta/Rakefile:5:in `<top (required)>'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
Approaches tried
gem install --user-install ffi -v '1.9.25' -- --enable-libffi-alloc
gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"
gem install ffi -v '1.9.25' --platform=rub
alias gem="arch -x86_64 sudo gem"
CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS='--with-readline-dir=/opt/homebrew/opt/readline' gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"
You need to install libffi using homebrew:
brew install libffi
Then the installation should succeed with:
gem install ffi
I've tested this on ruby 2.7.2 on my m1.
Also make sure that both libffi and ruby/gem are running on the same architecture. You may have mixed some arm64 and x86 binaries which will lead to lots of compiler errors in the long run. If you encounter "wrong architecture" errors, try to reinstall ruby/homebrew on arm/m1.
For reference:
I'm using chruby installed through homebrew and installed ruby 2.7.2 via ruby-install.
Both homebrew and ruby are not using rosetta emulation and are compiled on arm64. I've installed libffi using brew install and then installed ffi using gem install without problems.
pascal#0xc0fefe ~> which ruby
/Users/pascal/.rubies/ruby-2.7.2/bin/ruby
pascal#0xc0fefe ~> which ruby-install
/opt/homebrew/bin/ruby-install
pascal#0xc0fefe ~> file /Users/pascal/.rubies/ruby-2.7.2/bin/ruby
/Users/pascal/.rubies/ruby-2.7.2/bin/ruby: Mach-O 64-bit executable arm64
pascal#0xc0fefe ~> gem install ffi
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Done installing documentation for ffi after 0 seconds
1 gem installed
Here's the only workaround I found working, download Rosette, https://support.apple.com/en-us/HT211861, and uninstall (you need to do this in order for anything not compatible with the current architecture):
ruby versions
homebrew
rbenv
and select Get Info on Terminal, and check the Open using Rosetta.
Now reinstall
homebrew
rbenv
ruby
Run ruby -v
Check and verify that your version has ... [universal.x86_64-darwin21]
The thing is that official support for M1 was added in ffi v 1.14.0, so try update to that version, should not break anything.
gem uninstall ffi
and change manually in Gemfile.lock to 1.14.0.
gem install ffi -v '1.14.0'
This is what worked for me.
I've been trying to install a demo React Native App that innocently asked to run pod install and the went down this ffi rabbit hole.
On my M2 / Monterey, this article worked well except it was missing the instruction to install the ruby plugin for asdf
asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git

gem install rails -v 4.2.4 Failed to install

I receive the following error message when running this command:
gem install rails -v 4.2.4
This is the error:
/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:5: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/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)
Referenced from: /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
Reason: image not found - /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/psych.bundle
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/psych.rb:7:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/yaml.rb:6:in `<top (required)>'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:628:in `load_yaml'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:326:in `load_file'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/config_file.rb:198:in `initialize'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `new'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:40:in `run'
from /Users/adamgoldberg/.rvm/rubies/ruby-2.3.0/bin/gem:21:in `<main>'
Please Help - this is causing me nightmares
It seems your ruby installation is missing psych (for YAML output).
Install libyaml with Homebrew: http://brew.sh; then try gem install rails -v 4.2.4
$ brew info libyaml
libyaml: stable 0.1.6 (bottled)
YAML Parser
http://pyyaml.org/wiki/LibYAML
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libyaml.rb
==> Options
--universal
Build a universal binary
$ brew install libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.6_1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libyaml-0.1.6_1.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/libyaml/0.1.6_1: 8 files, 312.8K
REINSTALL RUBY
If the above solution doesn't work for you, reinstall Ruby from scratch with rvm or rbenv,
1) Try the instructions on this accepted answer: https://stackoverflow.com/a/38194139/1076207
—OR—
2) Remove all rvm files, then reinstall rvm: https://stackoverflow.com/a/38158619/1076207
—OR—
3) Remove all rvm files, then install rbenv: https://stackoverflow.com/a/38194231/1076207
After using one of the three options above, use http://bundler.io to install Rails:
$ mkdir ~/Documents/Repo
$ cd ~/Documents/Repo
$ gem install bundler
[…]
$ bundle init
Writing new Gemfile to /Users/username/Documents/Repo/Gemfile
$ echo "gem 'rails', '4.2.4'" >> Gemfile
$ bundle install
[…]
$ bundle exec rails new project_name
[…]
$ cd project_name
Personally, I recommend 3) switch to rbenv—I did.
The error itself clearly says that you should install libyaml first and then re-install your ruby. You can do it by running following commands.
sudo apt-get install libtool
rvm package install libyaml
rvm reinstall ruby-2.3.0
for more reference please see this answer

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 ?

rmagick preventing rails server from working

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

Resources