Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem::Ext::BuildError: ERROR: Failed to build gem native extension for rails version 4.2.6

Tags:

I have created new rails app and try to run bundle install it shows this error,

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-1.8.6/ext/json/ext/generator/usr/bin/ruby2.3 -r ./siteconf20170704-11395-12tpg5u.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/json-1.8.6 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.6/gem_make.out

An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling

Kindly send me some suggestions,Thanks in Advance.

like image 569
Pasupathi Thangavel Avatar asked Jul 04 '17 08:07

Pasupathi Thangavel


2 Answers

If you have a Mac or Linux machine try the following command:

sudo apt-get install ruby-dev

If that fails, what is your output for:

gem install json -v '1.8.6'

(please copy and paste all the output).

Similar issue

I'm not sure what will fix it for Mac, but people had positive experiences with brew install ruby.

like image 170
Mugur 'Bud' Chirica Avatar answered Sep 27 '22 20:09

Mugur 'Bud' Chirica


If anyone facing this error with Mac OS Big Sur, please update the ruby version to atleast 2.7. I am using rvm to resolve this issue.

like image 20
Ragu Avatar answered Sep 27 '22 21:09

Ragu