Edwin Harly Edwin Harly - 2 months ago 21
Ruby Question

I got this error while trying to install rails ERROR: Failed to build gem native extension. (Ubuntu 16.04)

My ruby version is

ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
. And my gem version is 2.5.1

I want to install rails, but when I try
sudo gem install rails

It gives me this error

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

current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20160905-4032-nlscry.rb extconf.rb
mkmf.rb cant find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out


Please let me know how to solve it, thank you.

Answer

try to install this dependencies

sudo apt-get install ruby-dev zlib1g-dev liblzma-dev build-essential patch

and then run gem install

Comments