Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get an error installing the JSON gem in Ubuntu?

Using Ubuntu, when I run "bundle install" to set up my Rails environment, it throws an error during the JSON gem installation:

Installing json (1.7.3) 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/danny/.bundler/tmp/2040/gems/json-1.7.3 for inspection.
Results logged to /home/danny/.bundler/tmp/2040/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.

When I try installing only the JSON 1.7.3 gem it also gives me an error:

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 `<main>'

Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.7.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out

I've installed RVM and am running Ruby 1.9.3; Why can't it install the JSON gem?

like image 418
TownWizard Avatar asked Jun 15 '12 22:06

TownWizard


1 Answers

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

sudo apt-get install ruby1.9.1-dev 
like image 74
Dylan Markow Avatar answered Oct 27 '22 04:10

Dylan Markow