11

I updated to the developer release of Lion and noticed I couldn't start rails apps anymore. Whenever I try to sudo bundle install, I get the following error:

Installing nokogiri (1.4.4) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Users/jamielawrence/Documents/Websites/atgdb/vendor/bundle/ruby/1.8/gems/nokogiri-1.4.4 for inspection.
Results logged to /Users/jamielawrence/Documents/Websites/atgdb/vendor/bundle/ruby/1.8/gems/nokogiri-1.4.4/ext/nokogiri/gem_make.out
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:504:in `each'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:504:in `build_extensions'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:180:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:101:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:78:in `preserve_paths'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/source.rb:91:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:58:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:93:in `with_build_args'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:57:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:49:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/installer.rb:8:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/cli.rb:222:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `send'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/bin/bundle:13
    from /usr/bin/bundle:19:in `load'
    from /usr/bin/bundle:19
Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
Jamie
  • 1,004
  • 1
  • 14
  • 32
  • Do you have Xcode installed? Do you have libxml2 and libxslt installed? These libraries are required by nokogiri. – Luis Lavena Jul 19 '11 at 20:24

8 Answers8

15

Try to install "libxslt1-dev" and "libxml2-dev" packages.

10

Thanks all - As i updated to Lion, I needed to install x code 4.1 to get the correct files behind the scenes for the bundler to install all of the correct bundles. All working sweet now!

Jamie
  • 1,004
  • 1
  • 14
  • 32
  • Thanks for the tip, ran into a similar issue with a VIM plugin. – Peter Brown Jul 22 '11 at 21:58
  • Keep in mind that unlike other apps you download from the Mac App Store you have to manually install XCode using the 'Install Xcode' application. – Marc Jul 25 '11 at 01:16
3

I found this worked via https://github.com/sparklemotion/nokogiri/issues/1166#issuecomment-56545974.

$ brew install libxml2
$ gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

Here's a more detailed approach if even this doesn't work. http://www.bullrico.com/2012/07/12/installing-nokogiri-after-updating-homebrew

Evolve
  • 8,939
  • 12
  • 51
  • 63
3

Install the ruby1.8-dev gem (or rather, the applicable *-dev gem), which will include all the header files. See: This question

Community
  • 1
  • 1
TinyTimZamboni
  • 5,275
  • 3
  • 28
  • 24
1

Consider installing a pre-1.6 version of nokigiri (gem install nokogiri -v '1.5.9')

NudeCanalTroll
  • 2,266
  • 2
  • 19
  • 43
  • Thanks! This solved my nokogiri intall issue on OSX 10.9.1 with XCode 5.0.2, Ruby 2.0.0 (nokogiri is a dependency for jekyll-import) – nicksuch Jan 15 '14 at 23:34
1

It says: "can't find header files for ruby". In other words, you're missing the ruby headers in order to compile libxml/nokogiri as a ruby extension.

Consider installing ruby 1.9 (or 1.8) using macports or rvm. I'm not 100% on the second, but the first will automatically make the relevant headers available.

Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154
0

I had similar problem, and after installing XCode 4.1, I also had to do the following command:

sudo port upgrade libxml2 libxslt

After that Nokogiri built without problems.

More info: http://tektastic.com/2011/07/ruby-mac-ports-and-os-x-lion.html

0

I tried a number of different solutions, but what finally worked for me was simply using a different version of 1.9.2.

I was having the same problem with 1.9.2-p280, but when I switched to 1.9.2-p180, I was able to install with out problems. Can't tell you why this worked, but it did.

I am running Lion and RVM (1.8.6).

Emerson
  • 536
  • 6
  • 9
  • Just had this problem again on an entirely different Lion system. Once again, the p180 worked, while the p280 did not. – Emerson Oct 28 '11 at 01:03