I've been despaired about "Failed to build gem native extension" - ruby-on-rails

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

Related

ERROR: Error installing racc: ERROR: Failed to build gem native extension

Ubuntu 20.04.2 LTS
Installing Rails 6.1.3.1
Ruby: 2.6.5
Installing rails:
gem install rails -v 6.1.3.1 --no-doc
Fails to install racc-1.5.2
Trying to manually install racc-1.5.2:
gem install racc -v '1.5.2' --source 'https://rubygems.org/' --no-doc
produces the same error.
The following is an 'edited' output of the error:
$ gem install rails -v 6.1.3.1 --no-doc
Fetching racc-1.5.2.gem
Fetching zeitwerk-2.4.2.gem
...
Successfully installed rack-2.2.3
Successfully installed rack-test-1.1.0
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /home/user/.rvm/gems/ruby-2.6.5#gemset/gems/racc-1.5.2/ext/racc/cparse
/home/user/.rvm/rubies/ruby-2.6.5/bin/ruby -I /home/user/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210503-658786-pkp97m.rb extconf.rb
checking for rb_ary_subseq()... yes
creating Makefile
current directory: /home/user/.rvm/gems/ruby-2.6.5#gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR=" clean
current directory: /home/user/.rvm/gems/ruby-2.6.5#gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR="
compiling cparse.c
linking shared-object racc/cparse.so
current directory: /home/user/.rvm/gems/ruby-2.6.5#gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR=" install
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:202: .sitearchdir.-.racc.time] Error 127
make install failed, exit code 2
Gem files will remain installed in /home/user/.rvm/gems/ruby-2.6.5#gemset/gems/racc-1.5.2 for inspection.
Results logged to /home/user/.rvm/gems/ruby-2.6.5#gemset/extensions/x86_64-linux/2.6.0/racc-1.5.2/gem_make.out
The main problem here is that the command mkdir is being called at a specific location, and it's just not there:
make: /usr/bin/mkdir: Command not found
To fix this, you need to add a symbolic link to that location:
$ sudo ln -s /bin/mkdir /usr/bin/mkdir
Run gem install again on rails and all should be good!
Thanks to user dem1tris from brining up a related topic, and providing the answer: make: /usr/bin/mkdir: Command not found during `gem install nokogiri` in Ubuntu 20.04

" ERROR: Failed to build gem native extension " in 16.04

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

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

gem install: ERROR: Failed to build gem native extension

I am using Arch Linux and installed Ruby (this is version 2.0.0).
When I installed Ruby it said I should add:
$(ruby -rubygems -e "puts Gem.user_dir")/bin
to my path, I added it to .bashrc
When I try to gem install rails or any other gem it gives the Error: Failed to build gem native extension. this is the full error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/lib/ruby/gems/2.0.0 directory.
[alexander#localhost ~]$ sudo gem install rails --no-user-install
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR="
sh: make: command not found
Gem files will remain installed in /usr/lib/ruby/gems/2.0.0/gems/atomic-1.1.10 for inspection.
When I look this error up I see that people solve this error by installing ruby-dev packages, however this does not exist for Arch Linux. Any other option that I can try?
Thanks in advance!
To build native extensions you need the c++-compiler and tools. This is said clearly:
sh: make: command not found
Except of make utility you obviously need the compiler itself (e. g. gcc) and company. Thus,
sudo apt-get install gcc
will do the trick. BTW, the properly suggested above RVM-way will definitely require build-tools as well.
try this commands
sudo apt-get install ruby1.9.1-dev build-essential
sudo apt-get install ruby-compass

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

Resources