安装 gem Nokogiri-1.8.4 时出错

Error on installing gem Nokogiri-1.8.4

OS: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

我在这里错过了什么?

从错误输出来看,它似乎找不到 Ruby 的开发依赖项,Nokogiri 试图使用它来本地构建 gem。

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

我的回答有点基于

更新

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

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

有效:)

尝试运行下面提到的命令

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