未能安装Nokogiri宝石

Kat*_*e H 16 ruby ruby-on-rails paperclip nokogiri rvm

我正在开发一个rails应用程序,允许每个使用帐户的图像附件.我正在使用paperclip和amazon网络服务:

gem 'paperclip'
gem 'aws-sdk'
Run Code Online (Sandbox Code Playgroud)

当我运行bundle install时,我收到以下消息:

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.
Run Code Online (Sandbox Code Playgroud)

当我尝试运行'gem install nokogiri'时,我收到以下消息:

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
Run Code Online (Sandbox Code Playgroud)

我的操作系统是Mac OS X 10.9.4 Mavericks.这里发生了什么?如何让nokogiri安装和行为正常?

完整堆栈跟踪:

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
Run Code Online (Sandbox Code Playgroud)

Kat*_*e H 29

这就像一个魅力!

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
Run Code Online (Sandbox Code Playgroud)

/sf/answers/1715780461/


kas*_*ite 8

你试过gem install nokogiri -v 1.6.5 -- --use-system-libraries吗?大多数nokogiri错误与libxml2,libxslt或libiconv配置有关.

Nokogiri 文档应该给你更多的指示.如果解决方案不起作用,您可能希望发布完整堆栈跟踪,以便其他人可以提供更多帮助.


equ*_*nt8 6

1.6.6.2在Ubuntu 14.04上升级到Rails 4.2.4(包括Nokogiri )后(我正在使用RVM),我需要这样做:

sudo apt-get install libgmp-dev
Run Code Online (Sandbox Code Playgroud)

要么

sudo apt-get install libgmp3-dev
Run Code Online (Sandbox Code Playgroud)


ken*_*orb 6

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

sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev
Run Code Online (Sandbox Code Playgroud)