Ruby on Rails 的 Nokogiri 问题 [英] Nokogiri issues with Ruby on Rails

查看:37
本文介绍了Ruby on Rails 的 Nokogiri 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的机器上安装 nokogiri,但收到以下错误:

I'm trying to install nokogiri on my machine but I am receiving the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.6.4/ext/nokogiri
/Users/username/.rbenv/versions/2.0.0-p481/bin/ruby -r ./siteconf20151127-29540-11ahx4h.rb extconf.rb
checking if the C compiler accepts ... *** 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=/Users/username/.rbenv/versions/2.0.0-p481/bin/ruby
    --help
    --clean
/Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
    from /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:500:in `with_werror'
    from /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
    from extconf.rb:80:in `nokogiri_try_compile'
    from extconf.rb:87:in `block in add_cflags'
    from /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/2.0.0/mkmf.rb:599:in `with_cflags'
    from extconf.rb:86:in `add_cflags'
    from extconf.rb:337:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/extensions/x86_64-darwin-14/2.0.0-static/nokogiri-1.6.6.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.6.4 for inspection.
Results logged to /Users/username/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/extensions/x86_64-darwin-14/2.0.0-static/nokogiri-1.6.6.4/gem_make.out

我不确定如何解决这个问题,因为我没有太多设置本机扩展的经验.任何帮助将不胜感激.如果需要提供更多信息,请告诉我.

I'm unsure how to go about fixing this as I do not have too much experience with setting up native extensions. Any help would be greatly appreciated. Let me know if more information needs to be presented.

推荐答案

这似乎是一个常见问题.您可以查看以下链接

This seems to be a common issue. You can check the following link

http://www.nokogiri.org/tutorials/installing_nokogiri.html

您需要将 Rubygems 更新到 2.4.5 或更高版本,并检查您的 PC 上是否安装了开发工具.

You will need to update the Rubygems to 2.4.5 or later and also check whether development tools is installed on you pc.

或者,如果您使用的是 bundle,您可以执行以下操作

Or you can do the following if you are using bundle

gem update --system
gem install nokogiri -- --use-system-libraries
bundle config build.nokogiri --use-system-libraries
bundle install

这篇关于Ruby on Rails 的 Nokogiri 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆