Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues installing Nokogiri 1.6.5 on OS X Yosemite (10.10.1) #1210

Closed
adamdullenty opened this issue Dec 17, 2014 · 16 comments
Closed

Issues installing Nokogiri 1.6.5 on OS X Yosemite (10.10.1) #1210

adamdullenty opened this issue Dec 17, 2014 · 16 comments
Assignees

Comments

@adamdullenty
Copy link

Hey,

I recently followed this guide to get my brand new MacBook set up in the same way as my Ubuntu box, but switching to chruby instead of rvm:

http://andycroll.com/mac/ruby/the-simplest-possible-serious-ruby-on-rails-setup-on-mavericks/

So my environment should be pretty clean.

However when trying to 'bundle install' I'm getting the following error for Nokogiri:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/me/.rubies/ruby-2.1.3/bin/ruby extconf.rb 

/Users/me/.rubies/ruby-2.1.3/bin/ruby: invalid option -2  (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/me/.gem/ruby/2.1.3/gems/nokogiri-1.6.5 for inspection.

Results logged to /Users/me/.gem/ruby/2.1.3/extensions/x86_64-darwin-14/2.1.0-static/nokogiri-1.6.5/gem_make.out

An error occurred while installing nokogiri (1.6.5), and Bundler cannot

continue.

Since then I have tried all of the relevant code snippets on here http://www.nokogiri.org/tutorials/installing_nokogiri.html with again no luck (and the error message I am seeing is different to the one highlighted on that page anyway)

Fairly new to OS X and Macs in general so not overly sure how to proceed.

Any ideas would be gratefully received.

@juliosousa
Copy link

I had a lot of trouble with this installation, but it solved for me:

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

@adamdullenty
Copy link
Author

No luck with that unfortunately, similar error:

Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2- lib=/usr/lib/'
This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/me/.rubies/ruby-2.1.3/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2- lib=/usr/lib/
/Users/me/.rubies/ruby-2.1.3/bin/ruby: invalid option -2  (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/me/.gem/ruby/2.1.3/gems/nokogiri-1.6.5 for inspection.

@zenspider
Copy link
Contributor

That "-2" is highly suspect. I don't have any idea how that'd come about. But, look at the first line:

Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2- lib=/usr/lib/'

That space in "with-xml2-[space]lib"? Try fixing that and trying again.

@neonichu
Copy link
Contributor

neonichu commented Jan 7, 2015

There's also an issue with latest OS X / Xcode and a check introduced in version 1.6.5 of Nokogiri, see #1218

@jkxyz
Copy link

jkxyz commented Jan 10, 2015

I found that this problem was fixed by running xcode-select --install and installing the command-line developer tools. I thought I had already installed them with Xcode, but I guess not.

@zenspider
Copy link
Contributor

@neonichu I know of no known issue with the latest OSX/xcode if my requirements/install instructions are followed. If you have details that reproduce an error within those parameters, please let us know.

@zenspider
Copy link
Contributor

I believe this ticket can be closed. I believe it was resolved on IRC. If I'm misremembering, then @adamdullenty needs to respond.

@adamdullenty
Copy link
Author

@zenspider Apologies for delay replying - no that wasn't me on IRC.

I fixed the rogue space and had the same error:

gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
Building native extensions with: '--use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/'
This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/adamdullenty/.rubies/ruby-2.1.3/bin/ruby extconf.rb --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
/Users/adamdullenty/.rubies/ruby-2.1.3/bin/ruby: invalid option -2  (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/adamdullenty/.gem/ruby/2.1.3/gems/nokogiri-1.6.5 for inspection.
Results logged to /Users/adamdullenty/.gem/ruby/2.1.3/extensions/x86_64-darwin-14/2.1.0-static/nokogiri-1.6.5/gem_make.out

I've since seen the same issue with other gems when gem updating - picked json randomly but it seems to be happening for loads of stuff:

Cheers.

@adamdullenty
Copy link
Author

Seems this is due to Xcode 5.1, see the accepted answer on this thread:

http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul

Easiest fix for now is to set this flag before installing, but in general it looks like this option won't be there forever and gems will need updating to not use any unrecognised command line switches:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

@neonichu
Copy link
Contributor

@adamdullenty IIRC, this flag being required was a combination of an issue in the Ruby that shipped with 10.9 and Xcode 5.1 - it doesn't happen on 10.10 anymore.

@flavorjones
Copy link
Member

I don't believe this is mac-specific, there's a post on nokogiri-talk reporting of the same issue on Ubuntu:

https://groups.google.com/d/msg/nokogiri-talk/-ajH8ho16zM/64eh9PrlW-8J

The post suggests this may be an issue with chruby ...

@adamdullenty
Copy link
Author

Might be right, and my previous post about Xcode 5.1 and the flag might have been a red herring as at the time I had switched from chruby to rvm.

@flavorjones
Copy link
Member

I am unable to reproduce this, running a fresh Vagrant image of Ubuntu 14.04 x64, within which is installed

  • ruby-installer 0.5.0
  • ... which installed ruby 2.1.3p242
  • chruby 0.3.9
  • nokogiri 1.6.5

Can anyone suggest further research I can do into this problem to reproduce it?

@adamdullenty
Copy link
Author

Another thing to rule out is whether RUBYOPT has been set by mistake as in
this thread:

postmodern/chruby#255

I can't remember setting this myself but on checking it it looks like it
has been erroneously set to '2.1' from somewhere.

Others having issues: try checking your RUBYOPT with "echo $RUBYOPT". If
it's set to 2.x.x (etc) it can be cleared with "unset RUBYOPT"

On Mon, Jan 12, 2015 at 2:19 PM, Mike Dalessio notifications@github.com
wrote:

I am unable to reproduce this, running a fresh Vagrant image of Ubuntu
14.04 x64, within which is installed

  • ruby-installer 0.5.0
  • ... which installed ruby 2.1.3p242
  • chruby 0.3.9
  • nokogiri 1.6.5

Can anyone suggest further research I can do into this problem to
reproduce it?


Reply to this email directly or view it on GitHub
#1210 (comment)
.

@flavorjones
Copy link
Member

Closing. If you can help me reproduce this somehow, I'm happy to reopen and investigate.

Thanks for using Nokogiri!

@holms
Copy link

holms commented Mar 3, 2016

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

This worked for me!!! Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants