3

I've recently tried to write a small scraping script with Ruby and Capybara; however, when I compile code that requires Capybara, I get the following error:

/Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/nokogiri.bundle:       dlopen(/Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/nokogiri.bundle, 9): Library  not loaded: /opt/local/lib/libiconv.2.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 - /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/nokogiri.bundle
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri.rb:27
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Gems/1.8/gems/capybara-1.1.2/lib/capybara.rb:2
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'

I've uninstalled and reinstalled nokogiri several times. I've checked to make sure the only install of Ruby on my Mac is in //usr/bin. I've recently updated Xcode and uninstalled MacPorts at Homebrew's behest. What have I done wrong, if anything, and what's the fix?

1 Answer 1

2

there are several things broken on the mac that make it quite hard to work with the onboard ruby stuff.

i would suggest using RVM or RBENV to manage your ruby installation (RVENV is more lowlevel though). removing MacPorts is a good idea. homebrew has less problems integrating into OS X.

run brew doctor to see any possible errors.

1
  • 2
    Turns out that MacPorts and Homebrew deal with libiconv differently. When I migrated from one to the other, I was running into some sort of inconsistency that was preventing Ruby et al. from running correctly. Whatever it was, uninstalling nokogiri and running gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8/ solved the problem.
    – malone
    Oct 15, 2012 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.