可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm working on a rails app that allows for image attachments to each use account. I'm using paperclip and amazon web services:
gem 'paperclip'
gem 'aws-sdk'
When I run bundle install, I get this message:
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling.
When I try running 'gem install nokogiri', I get this message:
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out
My OS is Mac OS X 10.9.4 Mavericks. What's going on here? How can I get nokogiri to install and behave properly?
Full stack trace:
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... yes
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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.
Provided configuration options:
--with-opt-dir
--without-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=/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby
--help
--clean
--use-system-libraries
--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-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.5 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.5/gem_make.out
回答1:
This works like a charm!
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
https://stackoverflow.com/a/24511149
回答2:
Have you tried gem install nokogiri -v 1.6.5 -- --use-system-libraries
?Most nokogiri errors are to do with libxml2, libxslt or libiconv config.
Nokogiri docs should give you more instructions. If the solution doesn't work, you may want to post full stack trace so others can help more.
回答3:
after upgrading to Rails 4.2.4 (which inculdes Nokogiri 1.6.6.2
) on Ubuntu 14.04 (I'm using RVM) I needed to do this:
sudo apt-get install libgmp-dev
or
sudo apt-get install libgmp3-dev
回答4:
On Ubuntu, try installing the following dependencies:
sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev
回答5:
I solved this by installing the xcode dependencies that Nokogiri needs to be installed:
xcode-select --install
After that run bundle install again and it should work.
回答6:
Since the OP was referencing bundle install
which I happened to use as well I think it is worth pointing out the Installing Nokogiri page which eventually revealed the most elegant solution (which worked for me also on Mac OS X 10.8.5):
bundle config build.nokogiri --use-system-libraries
bundle install
This instructs bundler to install nokogiri as in the answers of @kasperite
回答7:
Package that did it:
apt-get install libghc-zlib-dev
Other possible candidate:
zlib1g-dev
on 12.04
found it here
回答8:
As per the nokogiri installation instruction installing,
sudo apt-get install zlib1g-dev
solved the issue for me.
回答9:
I didn't get the same error message as you, but I wanted to note what I finally found as the extraordinarily simple solution for installing nokogiri on Ubuntu:
Turns out the nokogiri build process depends on patch
.
Run: sudo apt-get install patch
I was working on a VM (a vagrant box, actually), which is why I didn't already have patch
installed.
The error I got (after a lot of other stuff that looked like an error but was actually just a warning) was:
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /var/lib/gems/1.9.1/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/var/lib/gems/1.9.1/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened.
I've deleted the log by now (the above was in my terminal session), but the patch.log
file referenced above was absurdly simple; it just said something like patch not found
.
Boy did I feel silly for all the digging around I did installing libraries trying to fix it! :)
回答10:
install gcc first
in *buntu :
apt-get install gcc
after that U may requer most dev libs, such as
libxml2 / zlib / etc.
see build log(path in my case) :
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/mkmf.log
for string like - fatal error: zlib.h: No such file or directory
回答11:
To take from dylanjhunt's awesome answer on Github, just in case anyone hasn't tried it,
Just to add to this, I was having a very similar issue that was
resolved by updating dev tools.
xcode-select --install
Hoping someone sees this that had not tried doing this yet and it
helps.
回答12:
I had the same issue earlier today. I had updated my xcode and had not
agreed to the terms yet. Running sudo xcodebuild -license
and agreeing
got my bundle working again.
- https://github.com/CocoaPods/CocoaPods/issues/1727#issuecomment-194568428