Menu

Installing Nokogiri Fails on OS X Mavericks

So, I upgraded to OS X Mavericks this weekend. The upgrade went smooth and everything had been running extremely fine for me until today. I wanted to install the Ruby OpenGraph gem for a project I was working on. This gem depends on the Nokogiri Gem. However, unfortunately I was facing this issue which was failing on building of Nokogiri Native Extensions as follows.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

$gem install nokogiri

Building nativeextensions.Thiscould takeawhile...

ERROR:Error installing opengraph:

ERROR:Failed tobuild gem nativeextension.

/Users/jasdeep/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb

extconf.rb:10:UseRbConfig instead of obsolete anddeprecated Config.

checking forlibxml/parser.h...***extconf.rb failed ***

Could notcreate Makefile due tosome reason,probably lack of

necessary libraries and/orheaders.Check the mkmf.log file formore

details.You may need configuration options.

Provided configuration options:

--with-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/Users/jasdeep/.rvm/rubies/ruby-1.9.3-p448/bin/ruby

--with-zlib-dir

--without-zlib-dir

--with-zlib-include

--without-zlib-include=${zlib-dir}/include

--with-zlib-lib

--without-zlib-lib=${zlib-dir}/lib

--with-iconv-dir

--without-iconv-dir

--with-iconv-include

--without-iconv-include=${iconv-dir}/include

--with-iconv-lib

--without-iconv-lib=${iconv-dir}/lib

--with-xml2-dir

--without-xml2-dir

--with-xml2-include

--without-xml2-include=${xml2-dir}/include

--with-xml2-lib

--without-xml2-lib=${xml2-dir}/lib

--with-xslt-dir

--without-xslt-dir

--with-xslt-include

--without-xslt-include=${xslt-dir}/include

--with-xslt-lib

--without-xslt-lib=${xslt-dir}/lib

/Users/jasdeep/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in`try_do': The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.

from /Users/jasdeep/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'

So, i checked the gem_make.out where the errors were logged and figured my comman line developer tools in this new version of OS X were pooched/missing. There is a command line tool available called xcode-select which is used to switch between different versions of XCode and Xcode in this new version of OS X comes with an update (Version 5.0.1). This little tool can be used to install the latest command line developer tools.

This command did it for me:

1

$xcode-select--install

After downloading and installing the new Command Line Developer Tools:

PS: I had a few warnings after installing the gem which I’ve left out for brevity sake. These were just some encoding warnings – Nothing serious. I’m hoping there won’t be any major issues with Nokogiri on Mavericks.

unfortunatly, new major issues with Nokogiri on Mavericks…. seems to be the case with each new XCode release now …

yinghau76

You save my day. Thank you!

Alex

Thank you sir!

http://www.jeffkibuule.com Jeff Kibuule

SUCCESS!

kennygorman

Thx!!! helped a ton.

Stephen Benner

For those having issues related to creating the native extensions (libiconv especially) I’d like to share a Ruby script that acts as a self-contained solution and should work on any recent Mac OS X / Homebrew installations. It can configure and install using Bundler if you want–see the gist for details.