Ruby 安装 Nokogirl 错误,急救!

bluexuemei · 2014年10月07日 · 最后由 ericguo 回复于 2014年10月08日 · 3833 次阅读

C:\ruby\Ruby-2.1\bin>gem install nokogiri --platform x86-mingw32 Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension.

C:/ruby/Ruby-2.1/bin/ruby.exe extconf.rb Building nokogiri using packaged libraries. Building zlib-1.2.8 for nokogiri.


IMPORTANT! Nokogiri builds and uses a packaged version of zlib.

If this is a concern for you and you want to use the system library instead, abort this installation process and reinstall nokogiri as follows:

gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

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


Downloading zlib-1.2.8.tar.gz Downloading zlib-1.2.8.tar.gz ( 1%) Downloading zlib-1.2.8.tar.gz ( 4%) Downloading zlib-1.2.8.tar.gz ( 5%) Downloading zlib-1.2.8.tar.gz ( 6%) Downloading zlib-1.2.8.tar.gz ( 8%) Downloading zlib-1.2.8.tar.gz ( 10%) Downloading zlib-1.2.8.tar.gz ( 11%) Downloading zlib-1.2.8.tar.gz ( 12%) Downloading zlib-1.2.8.tar.gz ( 14%) Downloading zlib-1.2.8.tar.gz ( 16%) Downloading zlib-1.2.8.tar.gz ( 18%) Downloading zlib-1.2.8.tar.gz ( 19%) Downloading zlib-1.2.8.tar.gz ( 21%) Downloading zlib-1.2.8.tar.gz ( 23%) Downloading zlib-1.2.8.tar.gz ( 25%) Downloading zlib-1.2.8.tar.gz ( 27%) Downloading zlib-1.2.8.tar.gz ( 29%) Downloading zlib-1.2.8.tar.gz ( 30%) Downloading zlib-1.2.8.tar.gz ( 31%) Downloading zlib-1.2.8.tar.gz ( 32%) Downloading zlib-1.2.8.tar.gz ( 33%) Downloading zlib-1.2.8.tar.gz ( 34%) Downloading zlib-1.2.8.tar.gz ( 35%) Downloading zlib-1.2.8.tar.gz ( 37%) Downloading zlib-1.2.8.tar.gz ( 39%) Downloading zlib-1.2.8.tar.gz ( 41%) Downloading zlib-1.2.8.tar.gz ( 42%) Downloading zlib-1.2.8.tar.gz ( 43%) Downloading zlib-1.2.8.tar.gz ( 44%) Downloading zlib-1.2.8.tar.gz ( 45%) Downloading zlib-1.2.8.tar.gz ( 46%) Downloading zlib-1.2.8.tar.gz ( 48%) Downloading zlib-1.2.8.tar.gz ( 49%) Downloading zlib-1.2.8.tar.gz ( 51%) Downloading zlib-1.2.8.tar.gz ( 52%) Downloading zlib-1.2.8.tar.gz ( 54%) Downloading zlib-1.2.8.tar.gz ( 56%) Downloading zlib-1.2.8.tar.gz ( 57%) Downloading zlib-1.2.8.tar.gz ( 59%) Downloading zlib-1.2.8.tar.gz ( 61%) Downloading zlib-1.2.8.tar.gz ( 62%) Downloading zlib-1.2.8.tar.gz ( 63%) Downloading zlib-1.2.8.tar.gz ( 65%) Downloading zlib-1.2.8.tar.gz ( 67%) Downloading zlib-1.2.8.tar.gz ( 69%) Downloading zlib-1.2.8.tar.gz ( 71%) Downloading zlib-1.2.8.tar.gz ( 73%) Downloading zlib-1.2.8.tar.gz ( 75%) Downloading zlib-1.2.8.tar.gz ( 77%) Downloading zlib-1.2.8.tar.gz ( 78%) Downloading zlib-1.2.8.tar.gz ( 80%) Downloading zlib-1.2.8.tar.gz ( 82%) Downloading zlib-1.2.8.tar.gz ( 84%) Downloading zlib-1.2.8.tar.gz ( 86%) Downloading zlib-1.2.8.tar.gz ( 88%) Downloading zlib-1.2.8.tar.gz ( 89%) Downloading zlib-1.2.8.tar.gz ( 90%) Downloading zlib-1.2.8.tar.gz ( 91%) Downloading zlib-1.2.8.tar.gz ( 93%) Downloading zlib-1.2.8.tar.gz ( 95%) Downloading zlib-1.2.8.tar.gz ( 97%) Downloading zlib-1.2.8.tar.gz ( 99%) Downloading zlib-1.2.8.tar.gz (100%) Extracting zlib-1.2.8.tar.gz into tmp/i686-mswin32_100/ports/zlib/1.2.8... OK Running 'compile' for zlib 1.2.8... ERROR, review 'tmp/i686-mswin32_100/ports/ ib/1.2.8/compile.log' to see what happened. *** 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 --srcdir=. --curdir --ruby=C:/ruby/Ruby-2.1/bin/ruby --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/inclu --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.0/lib/mini_portile.rb :279:in block in execute': Failed to complete compile task (RuntimeError) from C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.0/lib/mi ni_portile.rb:271:inchdir' from C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.0/lib/mi ni_portile.rb:271:in execute' from extconf.rb:402:incompile' from C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.0/lib/mi ni_portile.rb:110:in cook' from extconf.rb:253:inblock in process_recipe' from extconf.rb:154:in tap' from extconf.rb:154:inprocess_recipe' from extconf.rb:377:in `

'

extconf failed, exit code 1

Gem files will remain installed in C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/gems/nok ogiri-1.6.3.1 for inspection. Results logged to C:/ruby/Ruby-2.1/lib/ruby/gems/2.1.0/extensions/x86-mswin32-10 0/2.1.0/nokogiri-1.6.3.1/gem_make.out

把 ruby 版本换成 1.9.3 或者 2.0 来试试看

@bluexuemei 我已经安装成功了,你再试试

谢谢@ywjno,我再试试

irb(main):001:0> require 'nokogirl'


It's actually spelled nokogiri, not nokogirl


=> true irb(main):002:0> require 'nokogirl' => false irb(main):003:0> require 'nokogirl' => false irb(main):004:0> 这是什么情况?

#4 楼 @bluexuemei 你确定 nokogiri 这几个字打对了么

在 windows 上装需要扩展支持的库就是活折腾。最好的解决方法就是放弃在 windows 上使用 ruby。 另外 nokogirl 这个名字不错哈哈。

哈哈,确实把名字弄错了,谢谢指正

#2 楼 @ywjno Ruby 最好还是装在 C 盘,之前我就被坑过,装 D 盘就不能做rake assets:precompile,还有这样你装的是预编译版本,所以其实 devkit 都不用的。。

#8 楼 @ericguo ,请教不用 devkit,怎么安装 nokogiri?

#9 楼 @bluexuemei 就是你在 2 楼的做法,x64-mingw32 或者 x86-mingw32 结尾的都是预编译版本。

#10 楼 @ericguo ,nokogiri 1.5.9 x86-mingw32 能安装成功,但是无法使用,nokogiri 1.6.3.1 x86-mingw32 不能安装成功,我的 ruby 版本为 2.1(非 rubyinstaller)

#8 楼 @ericguo 我装在 D 盘的 ruby 可以运行 rake assets:precompile 这个命令的, 至于装的是 x64-mingw32,貌似是 gem 自动根据系统来进行选择的吧,用 jruby 的话就会装 java 版的

#11 楼 @bluexuemei 编译 ruby 的编译器和 nokogiri 不兼容,换 rubyinstaller 吧。 还有 1.5.9 不包括 ruby21 的预编译 so 文件,所以无论如何都是不行的。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号