1

I decided to reinstall Rails on my Mac following the install Rails Guide but it's failing when it tries to gem install nokogiri. I'm running Mac OSX version 10.10.5 and have ruby version 2.2.1p85 currently installed.

I get the following errors:

Running git apply with /Users/parkour/.rvm/gems/ruby-2.0.0-p643/gems/nokogiri-1.6.7.2/patches/libxslt/0017-Updated-config.guess.patch... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Users/parkour/.rvm/gems/ruby-2.0.0-p643/gems/nokogiri-1.6.7.2/ports/x86_64-apple-darwin14.1.0/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

So far I've tried the following commands with no success:

brew install libxml2

(suggested here)

xcode-select --install
gem install nokogiri 
bundle config build.nokogiri --use-system-libraries
bundle install

(suggested here)

brew install libxml2 libxslt libiconv
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"

and

ARCHFLAGS="-arch x86_64" gem install nokogiri

(both suggested here)

Can anyone provide alternative solutions that might work?

Thank you in advance!

Community
  • 1
  • 1
parkour
  • 11
  • 1

2 Answers2

0

Install brew libs

brew tap homebrew/dupes
brew install libxml2 libxslt
brew install libiconv

then link your new iconv libs:

brew link libiconv

then install your gem

gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

If it doesn't work then you can try this. I am not sure though but it might work.

gem install nokogiri -v '1.6.7.1' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2
  • Hi Mohammad, I appreciate the quick response! This is the output I get when I run your solutions: > brew tap homebrew/dupes 'Warning: Tap homebrew/dupes already tapped.' > brew install libxml2 libxslt 'Warning: libxml2-2.9.3 already installed' 'Warning: libxslt-1.1.28_1 already installed' > brew install libiconv ' homebrew/dupes/libiconv-1.14 already installed' > sudo gem update --system – parkour Mar 26 '16 at 18:05
  • /specification.rb:17:in `require': cannot load such file -- stringio (LoadError) from /Users/parkour/.rvm/rubies/ruby-2.0.0- /specification.rb:17:in `' from /Users/parkour/.rvm/rubies/ruby-2.0.0- /2.0.0/rubygems.rb:1291:in `require' from /Users/parkour/.rvm/rubies/ruby-2.0.0-site_ruby/2.0.0/rubygems.rb:1291:in `' from /Users/parkour/.rvm/rubies/ruby-2.0.0-site_ruby/2.0.0/rubygems.rb:116:in `' from :1:in `require' from :1:in `' – parkour Mar 26 '16 at 18:17
  • then link your new iconv libs: brew link libiconv then install your gem gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 – Mohammad Shahadat Hossain Mar 26 '16 at 18:23
  • created 16 symlinks. However, I still get the previous error even if I run – parkour Mar 26 '16 at 18:36
0

[Update on 29.03.16]: I couldn't find a solution to resolve this using Terminal/Applications and ended up doing a backup restore. Thankfully, I do weekly Time Machine backups so no real harm done.

Thanks again Mohammad for your quick suggestions.

parkour
  • 11
  • 1