Errors using rspec, missing libraries after installing Homebrew and uninstalling MacPorts
Asked Answered
V

4

35

I may have taken one step too far beyond my knowledge. I installed Homebrew and after it continued to give me warnings about having MacPorts installed I uninstalled that. But now my rspec tests don't run.

These are the errors I get:

/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri.rb:13:in `require': dlopen(/Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /opt/local/lib/libiconv.2.dylib (LoadError)
  Referenced from: /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/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 - /Users/mark/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle
.....
.....

I've installed libiconv through Homebrew, but that didn't fix it. It's complaining about libiconv version numbers. Is this the problem?

What is going on here and what do I need to do?

Verjuice answered 19/4, 2011 at 9:14 Comment(1)
Where are libiconv*.dylib installed and what version numbers are in their namesTrover
V
83

I got things working again for anyone interested. I removed and re-installed nokogiri gem and everything seems to be working again.

Verjuice answered 25/4, 2011 at 22:22 Comment(4)
Encountered this exact problem today.System
Same problem here. everything seems to be working again after reinstalling. Thanks!Pelite
I created a new gemset with RVM and then it worked perfectly.Manometer
removing and installing fixed the problem. but I'd still like to thanks Nicholas for his detailed instructionsGad
R
15

Generally, this problem is caused by being unable to find the right libiconv. Here is how I solve my problem:

Check output of otool -L /usr/lib/libiconv.2.dylib. I got the following output:

/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Then I install libiconv with Homebrew, brew install libiconv, and show where it was installed using brew list libiconv. I got the following output:

/usr/local/Cellar/libiconv/1.14/bin/iconv
/usr/local/Cellar/libiconv/1.14/include/ (3 files)
/usr/local/Cellar/libiconv/1.14/lib/libcharset.1.dylib
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib
/usr/local/Cellar/libiconv/1.14/lib/ (3 other files)
/usr/local/Cellar/libiconv/1.14/share/doc/ (6 files)
/usr/local/Cellar/libiconv/1.14/share/man/ (6 files)

the libiconv is installed in /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib. Then I check verion of newly installed libiconv, otool -L /usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib, and I got the following output:

/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib:
/usr/local/opt/libiconv/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

The version is correct, and we need to make this library available for Ruby. Creating a symbol link is a quick solution:

sudo ln -s /usr/local/opt/libiconv/lib/libiconv.2.dylib /opt/local/lib/libiconv.2.dylib
Reed answered 5/12, 2012 at 3:18 Comment(2)
I think you can replace the last step by: brew link --force libiconv Anyhow, your answer is a very nice solution since it doesn't involve reinstalling nokogiri.Nammu
Thanks for this! Helped me immensely! I'm not sure for everyone, but I needed to add brew tap homebrew/dupes before brew found the libiconv formula.Pavyer
P
0

I had to re-install libxml-ruby in addition to nokogiri to get things working again.

Presser answered 11/9, 2012 at 15:13 Comment(0)
L
0

FWIW, I ran into the same issue and if you are vendorizing your gems, you will have to remove the offending gem from vendor/ruby as a gem uninstall + reinstall is not always efficient. I'm guessing bundler leaves cache remnants of gems and their respective libs even when running a fresh install.

Linkous answered 30/9, 2014 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.