Failed to Build Gem Extension Error Installing rails - ruby-on-rails

I'm on a fresh Ubuntu installation and using the guide to install rails found here.
When I get to the final sudo gem install rails, I get 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/nio4r-1.2.1/ext/nio4r
/usr/bin/ruby2.3 -r ./siteconf20160821-19665-u7rxlt.rb extconf.rb
mkmf.rb can't 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/nio4r-1.2.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_make.out

Try this
gem update --system 2.0.3
Ref: https://stackoverflow.com/a/17657242/4132578

Related

error installing rails on ubuntu 16.04 failed to build gem native extension

Here is the code I put in and then the error followed: I am currently figuring out rails headers and see what could be happening. I follwed this article https://gorails.com/setup/ubuntu/16.04
and this article: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
and nothing.
gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
rickus#rickus:~$ sudo gem install rails
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.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170928-18941-1fdewid.rb extconf.rb
mkmf.rb can't 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.8.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.1/gem_make.out
Im also come up with this issue where I installed ruby environment manager rvm/ rbenv using sudo command.you can reinstall your ruby environment manager and avoid using sudo command or else all your gem installations would need sudo commands which you should avoid to prevent conflicts in the future.

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.
try to install this dependencies
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev build-essential patch
and then run gem install

Error installing gem twitter on Ubuntu 15.04

Am trying to install twitter gem on Ubuntu 15.04 and this error keeps popping up
gem install twitter
Building native extensions. This could take a while...
ERROR: Error installing twitter:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb
mkmf.rb can't 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.1.0/gems/http_parser.rb-0.6.0 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/http_parser.rb-0.6.0/gem_make.out
You are getting this error because there is no ruby development environment installed. Development environment is needed to compile ruby extensions,
You should install development first using command below:
$ sudo apt-get install ruby-dev
I had a similar issue and i solved it by installing ruby-dev:
sudo apt-get install ruby-dev

Ruby Compass ERROR: Failed to build gem native extension

Hi I am running Ubuntu 15.04 and I am trying to install the Compass gem. I did a gem update like the Compass website told me to do. Then I tried to install Compass and got the following error.
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 -r ./siteconf20150609-16406-5iavn8.rb extconf.rb
mkmf.rb can't 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.1.0/gems/ffi-1.9.8 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86-linux/2.1.0/ffi-1.9.8/gem_make.out
This is the output from the gem_make.out file
/usr/bin/ruby2.1 -r ./siteconf20150609-16446-49gin0.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Not sure what to do at this point. Thanks!
mkmf.rb can't find header files for ruby at
You need the ruby dev headers files to compile gems.
You need the package ruby2.1-dev.
You may also need other packages like build-essential.
Try the following:
sudo apt-get install ruby2.1-dev build-essential
On earlier versions of Ubuntu such as 14.04, you will need the ruby2.0-dev package instead.
sudo apt-get install ruby2.0-dev build-essential

Gem Install memcached-northscale error

Trying to install memcached-northscale and getting a weird error. Any help would be appreciated.
$ sudo gem install memcached-northscale
Building native extensions. This could take a while...
ERROR: Error installing memcached-northscale:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
I was able to fix the issue by installing XCode from Apple

Resources