我正在尝试在 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 时似乎发生了错误。
Troubleshooting Ubuntu / Debian Installation
If you have issues, first make sure you have all the tooling necessary to compile C extensions:
- 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:
- 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/