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

Error installing Nokogiri via Bundler on Windows

我正在尝试在我的 Windows 机器上设置 运行 Extreme Startup 编码道场。

当我到达 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 用户,我需要一些帮助。

我已经尝试了 的建议,但其中 none 有效。

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

这与其说是一个合适的解决方案,不如说是一种解决方法,但是 Gemfile.lock 中的依赖项已经很旧了,所以无论如何刷新它们都是一件好事。