在Ubuntu上安装Nokogiri失败

时间:2018-12-05 11:08:02

标签: ruby ubuntu nokogiri

我正在尝试在Ubuntu Linux上安装nokogiri。我正在运行Ruby-2.1.1。我已经安装了。

输出:

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

    current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20181205-6502-3n3u4g.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.8.5 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.8.5/gem_make.out

任何人都可以解释我所缺少的吗?

1 个答案:

答案 0 :(得分:0)

尝试使用rbenv安装Ruby 2.1.1,并将其设置为ubuntu中的默认版本:

    rbenv install 2.1.1
    rbenv global 2.1.1

在安装ruby之后,安装以下软件包:

sudo apt-get install libxslt-dev libxml2-dev zlib1g-dev

然后安装nokogiri:

sudo gem install nokogiri

这应该可以解决问题...