ruby – 安装Nokogiri时出错? mini_portile不可用?

我的本地宝石列表

bundler (1.6.0)
childprocess (0.5.1)
ffi (1.9.3)
headless (1.0.1)
json (1.8.1)
mini_portile (0.5.3, 0.5.2)
minitest (5.3.1)
multi_json (1.9.0)
rake (10.2.2)
rdoc (4.1.1)
rubyzip (1.1.2)
selenium-webdriver (2.41.0, 2.40.0)
watir-webdriver (0.6.8)
websocket (1.0.7, 1.0.4)

我还安装了libxml2和libxslt.
它说无法加载mini_portile gem,但它显示在本地gem列表中.

我也不能sudo,因为我没有root权限.

错误信息

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

        /usr/bin/ruby1.9.1 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=/usr/bin/ruby1.9.1
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mini_portile (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:92:in `<main>'


Gem files will remain installed in /home/jotsarup/.gem/gems/nokogiri-1.6.1 for inspection.
Results logged to /home/jotsarup/.gem/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out

最佳答案 如果您正在使用Ubuntu,请先尝试安装nokogiri要求.

sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri

其他明智的关注此链接Nokogiri Installation

点赞