简体   繁体   English

未能安装Nokogiri宝石

[英]Failing to install Nokogiri gem

I'm working on a rails app that allows for image attachments to each use account. 我正在开发一个rails应用程序,允许每个使用帐户的图像附件。 I'm using paperclip and amazon web services: 我正在使用paperclip和amazon网络服务:

gem 'paperclip'
gem 'aws-sdk'

When I run bundle install, I get this message: 当我运行bundle install时,我收到以下消息:

extconf failed, exit code 1 extconf失败,退出代码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: 当我尝试运行'gem install nokogiri'时,我收到以下消息:

extconf failed, exit code 1 extconf失败,退出代码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. 我的操作系统是Mac OS X 10.9.4 Mavericks。 What's going on here? 这里发生了什么? How can I get nokogiri to install and behave properly? 如何让nokogiri安装和行为正常?

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

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 https://stackoverflow.com/a/24511149

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. 您是否尝试过gem install nokogiri -v 1.6.5 -- --use-system-libraries ?大多数nokogiri错误与libxml2,libxslt或libiconv config有关。

Nokogiri docs should give you more instructions. Nokogiri 文档应该给你更多的指示。 If the solution doesn't work, you may want to post full stack trace so others can help more. 如果解决方案不起作用,您可能希望发布完整堆栈跟踪,以便其他人可以提供更多帮助。

在Ubuntu上,尝试安装以下依赖项:

sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev

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: 在Ubuntu 14.04(我正在使用RVM)上升级到Rails 4.2.4(其中包含Nokogiri 1.6.6.2 )后,我需要这样做:

sudo apt-get install libgmp-dev

or 要么

sudo apt-get install libgmp3-dev

As per the nokogiri installation instruction installing, 按照nokogiri安装说明安装,

sudo apt-get install zlib1g-dev

solved the issue for me. 为我解决了这个问题。

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): 由于OP正在引用bundle install ,我碰巧也使用它,我认为值得指出的是安装Nokogiri页面,它最终显示了最优雅的解决方案(在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 这指示捆绑者在@kasperite的答案中安装nokogiri

I solved this by installing the xcode dependencies that Nokogiri needs to be installed: 我通过安装Nokogiri需要安装的xcode依赖项解决了这个问题:

xcode-select --install

After that run bundle install again and it should work. 之后再次运行bundle install,它应该可以工作。

Package that did it: 做它的包:

apt-get install libghc-zlib-dev

Other possible candidate: 其他候选人:

zlib1g-dev on 12.04 zlib1g-dev于12.04

found it here 这里找到

To take from dylanjhunt's awesome answer on Github , just in case anyone hasn't tried it, Gyub上的dylanjhunt的精彩答案中获取 ,万一有人没有尝试过,

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. 希望有人看到这个还没有尝试这样做,这有帮助。

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: 我没有得到与您相同的错误消息,但我想要注意我最终发现的在Ubuntu上安装nokogiri的非常简单的解决方案

Turns out the nokogiri build process depends on patch . 原来nokogiri构建过程取决于patch

Run: sudo apt-get install patch 运行: 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. 我正在研究VM(实际上是一个流浪盒),这就是我没有安装patch

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; 我现在已经删除了日志(以上是在我的终端会话中),但patch.log文件非常简单; it just said something like patch not found . 它只是说patch not found

Boy did I feel silly for all the digging around I did installing libraries trying to fix it! 男孩,我觉得愚蠢的所有挖掘我安装库试图解决它! :) :)

install gcc first 先安装gcc

in *buntu : apt-get install gcc 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 之后,U可能会重新获取大多数开发库,例如libxml2 / zlib /等。请参阅构建日志(在我的案例中为路径):/ var / lib / gems / 2.3.0 / extensions / x86_64-linux / 3.3.0 / nokogiri- 1.6.8.1/mkmf.log for string like - 致命错误:zlib.h:没有这样的文件或目录

I had the same issue earlier today. 我今天早些时候遇到了同样的问题。 I had updated my xcode and had not agreed to the terms yet. 我更新了我的xcode,但尚未同意这些条款。 Running sudo xcodebuild -license and agreeing got my bundle working again. 运行sudo xcodebuild -license并同意让我的捆绑再次运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM