2

I am trying to install rails on an amazon-linux instance, but I keep getting the same error reported in this question:

[ec2-user@xxx.xxx ~]$ 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

Note that I manually upgraded ruby to 2.3

[ec2-user@xxx.xxx ~]$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]

I've also tried with another versions of rails (I'd like to install the latest, 5.1.1), with also no luck

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

Is this possible at all or do I need to downgrade ruby to 2.0?

rhoanan
  • 21
  • 1

1 Answers1

5

It seems the error occurred while compiling nokogiri.

The nokogiri docs says

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
Community
  • 1
  • 1
thaleshcv
  • 752
  • 3
  • 7