在Windows上通过Bundler安装Nokogiri时出错

时间:2015-08-26 10:28:13

标签: ruby windows bundler

我试图在我的Windows机器上设置并运行Extreme Startup编码dojo。

当我到达bundle install步骤时,我收到以下错误消息:

$ bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing builder 3.2.2
Installing nokogiri 1.4.5 with native extensions

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

    c:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150826-3512-ilnke5.rb extconf.rb
*** 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=c:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:10:in `<main>': uninitialized constant Config (NameError)

extconf failed, exit code 1

Gem files will remain installed in c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.4.5 for inspection.
Results logged to c:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/nokogiri-1.4.5/gem_make.out
An error occurred while installing nokogiri (1.4.5), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.4.5'` succeeds before bundling.

根据documentation for Nokogiri,它只是应该工作,从某种意义上说,它确实有效,因为如果我发出命令gem install nokogiri,它 工作,但是安装nokogiri-1.6.6.2-x64-mingw32

据我了解bundle install的错误消息,它特别想要版本1.4.5。至少,即使安装了nokogiri-1.6.6.2-x64-mingw32bundle install仍会因上述错误消息而失败。

这可能是一个简单的问题,但由于我是新手ruby用户,我可以使用一些帮助。

我已经尝试过Error installing Nokogiri on bundle install but already installed的建议,但都没有。

1 个答案:

答案 0 :(得分:2)

这个特殊版本的Nokogiri列在Gemfile.lock中。您可以删除该文件,再次运行bundle install并查看它是否有效。

这是一个解决方法,而不是一个正确的解决方案,但Gemfile.lock中的依赖关系已经很老了,所以无论如何刷新它们都是一件好事。