安装gem Nokogiri-1.8.4时出错

时间:2018-08-01 08:23:28

标签: ruby amazon-ec2 rubygems nokogiri

操作系统:AMI 2018.03.0(HVM)
Ruby版本:2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux-gnu]-使用yum install ruby23

安装

gem安装nokogiri引发:

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

current directory: /home/ec2-user/.gem/ruby/2.3/gems/nokogiri- 
1.8.4/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20180801-6218-101te4s.rb extconf.rb
mkmf.rb can't find header files for ruby at 
/usr/share/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/ec2- 
user/.gem/ruby/2.3/gems/nokogiri-1.8.4 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.3/extensions/x86_64- 
linux/2.3/nokogiri-1.8.4/gem_make.out

我在这里想念什么?

2 个答案:

答案 0 :(得分:2)

从错误输出中,似乎找不到Nokogiri试图使用Ruby进行开发的依赖关系,以原生地构建gem。

您可以运行yum -y install gcc ruby-devel rubygems以确保已安装依赖项。

根据https://stackoverflow.com/a/4502672/1129980

更新

现在在新的EC2实例上对此进行了测试:

yum install -y ruby23-devel gcc libxml2 libxml2-devel libxslt libxslt-devel patch
gem install nokogiri --no-ri --no-rdoc

可行:)

答案 1 :(得分:0)

尝试运行以下提到的命令

sudo yum -y install ruby-dev ( or ruby-devel)
sudo yum -y install libgmp-dev libgmpxx4ldbl ruby-dev ruby2.3-dev