1

Install fails showing:

checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
libiconv is missing.

However, looking at nokogiri's mkmf.log, the following errors are shown:

ld: warning: ignoring file /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib

ld: warning: ignoring file /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib

ld: warning: ignoring file /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib

I have xcode and it's command tools installed. My ~/.bash_profile has 64bit compiling forced by: export ARCHFLAGS="-arch x86_64"

I have libxml2, libxslt, and libiconv installed via Homebrew, and each is linked. I've tried installing all of these without the ARCHFLAG in .bash_profile.

I've also brew install apple-gcc42 and linked, as per how tos I've found.

I've tried installing nokogiri by passing paths to libxml2, libxslt, and libiconv in /usr/local/Cellar/, but the install still fails, with same errors as above.

I've wasted at least a day on this - just trying to get one Ruby gem installed. I'd really like to get back to actually developing.

Can anyone please help?

  • Which ruby are you using? Default OS X or an RVM-managed ruby? With an RVM-managed 2.1.1 I have no problem doing 'gem install nokogiri'. I'm using XCode 5.1.1. It builds and installs its own libxml2 and its installing nokogiri-1.6.3.1. – Ian C. Jul 31 '14 at 20:20
1

You can't assume that the version of ruby built-into OS X is compatible with any gems you want to use. Do not try to remove the version of ruby that ships with OS X or update or upgrade it unless with App Store/Software Update/softwareupdate. Most rubiers will tell you don't even bother useing the ruby that ships with OS X. But you can install multiple versions of ruby, and you'll definately need a ruby version manager if you intend to use lots of gems.

ruby was once quite easy to use, but now, the number of versions that necessarily need to be supported are legion, and gem developers sometimes force you to install a new version of ruby at some other version when you already have a perfectly good ruby installation! Grr. ruby is really starting to chafe, because while the support information might be out there, it is looking more and more like a fishing reel that has birdnested. IMO, ruby is broken, someone's going to have to pull it out and get it neatly reeled in for it to be fixed, and I'm just not up to it. I'm not the guy. Not me.

brewinistas enthusiasm notwithstanding, the homebrew package manager has growing pains typical of an immature package management solution. I use MacPorts to manage... all my installations, but also the various versions of ruby installations that are necessary to use the gems I want. MacPorts requires an appropriate version of xcode; xcode_5.1.1.dmg is the most recent version for Mavericks. rvm uses MacPorts by default if it is installed.

It appears from your provided logs that you're missing stuff. That's what's nice about MacPorts (and any mature package manager); it takes care of the dependecies for you if they're not installed.

Install MacPorts

 curl -Ok https://distfiles.macports.org/MacPorts/MacPorts-2.2.1.tar.bz2

 tar xf MacPorts-2.2.1.tar.bz2

 cd MacPorts-2.2.1

 ./configure

 make

 sudo make install

 cd ..

 rm -rf Macports-*

 sudo /opt/local/bin/port -v selfupdate

add MacPorts to your $PATH:

 export PATH=/opt/local/bin:/opt/local/sbin:$PATH

take a look at what MacPorts has for ruby

 port search ruby |less

and/or just install nokogiri

 sudo port -vsk install ruby19 libxml2 libxslt 

 sudo gem install nokogiri

 port -vfp clean ruby19 libxml2 libxslt

if there's trouble try

 sudo port upgrade outdated

MacPorts won't affect OS X version of anything, nor homebrew (except to make it superfluous) and keeps everything it installs in /opt making deinstallation a breeze (but this has nothing to do with where ruby keeps its gems, ~/.gem ). But you should really get to know and love MacPorts, it is your friend.

to completely uninstall MacPorts

 sudo port -dfp uninstall --follow-dependencies installed

 sudo port -dfp uninstall all

 sudo rm -rf /opt/local  

 sudo rm -rf /Library/Tcl/macports*
  • Thanks, I've tried this and still get similar errors relating to i386/x64 (I can't format here): ld: warning: ignoring file /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26/lib/libxslt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /Library/Ruby/Gems/2.0.0/gems/noko 85 ld: warning: ignoring file /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0/lib/libxml2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /Library/Ruby/Gems/2.0.0/gems/nokog – user3591456 May 2 '14 at 3:27
  • You haven't said what system you're using... perhaps its as simple as forcing the system to use the 64-bit kernel (if you're on 10.6, subsequent Systems should be using a 64-bit kernel already). To ensure 64-bit mode, hold down the '6' and '4' keys when the Mac starts up; or open Terminal and enter: nvram boot-args="arch=x86_64" You reset to 32-bit mode as follows: sudo nvram boot-args="" – chillin May 5 '14 at 23:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .