ruby-on-rails - 无法在 Linux 上安装 Rails : “Failed to build gem native extension” with ruby 2. 3

标签 ruby-on-rails ruby linux amazon-ec2 yum

我正在尝试在 amazon-linux 实例上安装 Rails,但我不断收到报告的相同错误 in this question :

[<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9efbfdacb3ebedfbecdee6e6e6b0e6e6e6" rel="noreferrer noopener nofollow">[email protected]</a> ~]$ sudo gem install rails --no-ri --no-rdoc
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/ruby/gems/2.3/gems/nokogiri-1.7.2/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170529-26560-9zyb13.rb extconf.rb

请注意,我手动将 ruby​​ 升级到了 2.3

[<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7b2b4e5faa2a4b2a597afafaff9afafaf" rel="noreferrer noopener nofollow">[email protected]</a> ~]$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]

我还尝试过其他版本的 Rails(我想安装最新的 5.1.1),但也没有成功

sudo gem install rails --version 5.1.1 --no-ri --no-rdoc
sudo gem install rails --version 5.0.0 --no-ri --no-rdoc
sudo gem install rails --version 4.2.8 --no-ri --no-rdoc

这是否可能,或者我是否需要将 ruby​​ 降级到 2.0?

最佳答案

编译 nokogiri 时似乎发生了错误。

nokogiri docs

Troubleshooting Ubuntu / Debian Installation

If you have issues, first make sure you have all the tooling necessary to compile C extensions:

  1. sudo apt-get install build-essential patch

It’s possible that you don’t have important development header files installed on your system. (This has never happened to me personally, but I have it on good authority that otherwise good and noble Ruby developers run into this.) Here’s what you should do if you should find yourself in this situation:

  1. sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

关于ruby-on-rails - 无法在 Linux 上安装 Rails : “Failed to build gem native extension” with ruby 2. 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44239377/

相关文章:

ruby-on-rails - Rails - 给定文本 block ,自动链接

ruby-on-rails - Searchkick如何显示存储桶键的联接表值

ruby-on-rails - rails : Controlling browser back button

ruby-on-rails - 在 Rails 中为长期运行 (Open4) 流程构建进度指示器

mysql - mysql_ssl_rsa_setup 从哪里获取 OpenSSL 文件?

ruby-on-rails - 将自由格式的 sql 转换为事件记录

ruby-on-rails - rubymine 输出 - 如何显示看跌期权

ruby-on-rails - Rails 4 错误:ActiveRecord::RecordNotFound/找不到 'id' =

linux - 使用 sed 或 awk 从文件中删除函数

linux - 什么是 unix/linux 内部机制?