" ERROR: Failed to build gem native extension " in 16.04 - ruby-on-rails

I was trying to install Sass. Went through this guide to install Ruby which Sass website told is a pre-requisite
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-and-set-up-a-local-programming-environment-on-ubuntu-16-04
Looks like it went well
$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
Now I am stuck at this point. I am not sure how to proceed further. I am using Ubuntu 16.04
$ sudo gem install sass
Building native extensions. This could take a while...
ERROR: Error installing sass:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20171122-3627-1olbmft.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/ffi-1.9.18 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/gem_make.out
What should I do now ? Please help.

sudo apt-get install ruby-dev
The above command fixed it for me.

Try installing libffi-dev
sudo apt-get install libffi-dev

Related

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

I've been despaired about "Failed to build gem native extension"

I installed rvm and ruby 2.0.0 on my ubuntu 13.04 and everything was fine, but the last step went wrong when I install rails 4.0.0
The following is what happened after I run: " gem install rails -v 4.0.0 ":
**Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/adolph/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
creating Makefile
make
compiling atomic_reference.c
linking shared-object atomic_reference.so
make install
/usr/bin/install -c -m 0755 atomic_reference.so /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/usr/bin/install: cannot create regular file ‘/home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux’: No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14 for inspection.
Results logged to /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/ext/gem_make.out**
It looks like the *‘/home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux’* doesn't exist.
Please help me!
You can try with this
sudo apt-get install build-essential
and after it
sudo gem install rails

Error while trying to gem install json under Ubuntu 12.04

Catching this error under Ubuntu 12.04:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/home/allaud/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
linking shared-object json/ext/generator.so
gcc: error: generator.o: No such file or directory
make: *** [generator.so] Ошибка 1
Gem files will remain installed in /home/allaud/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.7 for inspection.
Results logged to /home/allaud/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
I am using fresh rvm and ruby 1.9.3 and have same trouble only with json gem.
The error occurs when I try to execute:
gem install json
If I add sudo everything is ok, but I cannot (and shouldn't) use sudo with rvm commands.
sudo apt-get install ruby1.9.1-dev
may fix it .Cheers !
Try running below commands(works for ubuntu 14.04):
$ sudo apt-get install libgmp3-dev
and then install json
$ gem install json
Reference: https://www.digitalocean.com/community/questions/how-do-i-fix-this-error-when-deploying-rails-with-capistrano-using-nginx-and-puma
For me this worked (a solution from #mjgpy3)
sudo apt-get install ruby-json

mod_rails make: command not found

I'm setting up mod_rails on a Debian server but somehow something got screwed up (it wasn't me :P ).
gem install passenger
Building native extensions. This could take a while...
ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
creating Makefile
make
sh: make: command not found
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/fastthread-1.0.7/ext/fastthread/gem_make.out
gem is installed:
gem -v
1.3.5
ruby also fine:
ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Are you sure you have make, gcc et al?
$ sudo apt-get install build-essential
Does "which make" point to anything?
apt-get install build-essential zlib1g-dev libssl-dev libreadline5-dev
This should be everything you need to get passenger to build

Resources