6

Hey I am new to rails (as well as linux) and I keep getting this error:

Installing json (1.7.5) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.9.1 extconf.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file  -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'


Gem files will remain installed in /home/jack/.bundler/tmp/10426/gems/json-1.7.5 for inspection.
Results logged to /home/jack/.bundler/tmp/10426/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
jack@jack-ThinkCentre:~/rails_projects/sample_app$ 

I cant install the gem individually or with bundle install. I used rvm to install rails. thanks in advance.

Jakxna360
  • 857
  • 2
  • 9
  • 31
  • what happens when you try 'gem install json' separately? – hrr Nov 30 '12 at 20:46
  • Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from extconf.rb:1:in `
    ' Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.7.5 for inspection. Results logged to /var/lib/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
    – Jakxna360 Nov 30 '12 at 20:48
  • Is this the first time using rails? What's ur OS? If OSX: What XCode version do u have (xcodebuild -version)? – hrr Nov 30 '12 at 20:55
  • Try upgrading your Ruby and reinstalling gems. – hrr Nov 30 '12 at 21:27
  • I get this error: Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from extconf.rb:1:in `
    ' Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.7.5 for inspection. Results logged to /var/lib/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
    – Jakxna360 Nov 30 '12 at 21:32
  • @polarblau what are you talking about? – Jakxna360 Nov 30 '12 at 21:56
  • How do you do that? I don't see a button to do that? – Jakxna360 Nov 30 '12 at 22:01
  • Go to your account page. / Open a question you had previously asked. / See if someone has provided an answer which solved your problem. / Accept this answer by clicking the green checkmark beneath the votes counter on the left side to the answer. (— Please familiarize yourself a bit with how SO works before you carry on. Cheers!) – polarblau Dec 01 '12 at 11:35

2 Answers2

10

Installing the ruby1.9.1-dev package should fix this for you

sudo apt-get install ruby1.9.1-dev
niels
  • 1,719
  • 10
  • 20
Gowri Naidu R
  • 1,964
  • 2
  • 13
  • 15
2

"The same issue on ubuntu-trusty-64 running ruby 2.2.3. the solution is to install libgmp3-dev."

sudo apt-get install libgmp3-dev
Leopold
  • 21
  • 3