I require the json ruby gem to test some JSON files in Rspec. I use bundler to manage my gems, with my Gemfile looking as such:
source 'https://rubygems.org'
gem 'rake'
gem 'rspec'
gem 'json', '1.8.2'
However when I run bundle install everything passes but the json gem. Of which I get the following error message:
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 /var/lib/gems/1.9.1/gems/json-1.8.2 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.2/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that 'gem install json -v '1.8.2'` succeeds before bundling.
I've already looked around and seen this suggestion:
sudo apt-get install libgmp3-dev
I've done this but the error is still present. The gem version I'm trying to install is 1.8.2, my ruby version is ruby 1.9.3p484 as this is the last stable release for Ubuntu 14.04 as far as I'm aware
If anyone could help resolve this I'd be very grateful
Related
I'm trying to install Rails on Ubuntu 12.10 using the Ruby Version Manager. I believe that Ruby and RubyGems are installed correctly, and these are my versions:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
gem -v: 1.8.23
I'm trying to install rails, using
sudo gem install rails -v 3.2.9
This fetches a lot of gems, but has a problem building the native extensions:
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 `<main>'
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
Any idea what I'm doing wrong? If it helps, I'm trying to follow the tutorial at http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-install_rails.
Thank you!
Install the gem as a normal user, not sudo:
gem install rails
Or install the ruby dev package. There are a lot of similar answers in SO:
Failed to build gem native extension — Rails install
Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)
Do you have a C compiler installed? If not, you should run sudo apt-get install build-essential to set up a compiler toolchain
I'm having problems when I try to rake db:migrate. I get the following error:
Could not find json-1.7.5 in any of the sources
Run `bundle install` to install missing gems.
Now, I've already run bundle install and it gave an error when it got to json, but I try it again anyway and get the same error when it gets to json:
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'
Gem files will remain installed in
/home/chris/.bundler/tmp/2984/gems/json-1.7.5 for inspection. Results
logged to
/home/chris/.bundler/tmp/2984/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.
The last part says to make sure gem install json -v '1.7.5' succeeds before bundling, so I run this command and json installs fine:
Building native extensions. This could take a while...
Successfully installed json-1.7.5
1 gem installed
Installing ri documentation for json-1.7.5...
Installing RDoc documentation for json-1.7.5...
But if I try rake db:migrate it starts all over again with the same errors. I've read about issues with json on Mac, but have had no luck with any of those solutions. Any ideas?
I'm running Ubuntu 12.04LTS, ruby 1.9.3, rails 3.2.8, gem 1.8.15 (tried it with 1.9.1 also)
I think that you need to install the -dev package. Try running this command
sudo aptitude install ruby1.9.1-dev
and then bundle install should work.
Good day.
I'm trying to set up project that's beings worked on by other people.
when i run bundle install it crashes with an error
Installing bcrypt-ruby (3.0.1) 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:36:in `<main>'
Gem files will remain installed in /home/halfros/.bundler/tmp/9279/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /home/halfros/.bundler/tmp/9279/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
sudo gem install bcrypt-ruby -v '3.0.1'
$ sudo gem install bcrypt-ruby -v '3.0.1'
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
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:36:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
Tried ths - no changes.
http://rorguide.blogspot.com/2011/02/bundle-install-on-linux-giving-error.html
It looks like the ruby development library isn't installed.
It also looks like you're using global ruby/gems installation, so your easiest fix is to install the ruby1.9-dev package (or something similar), and try again.
Alternatively, you could use rvm and this problem will fix itself: https://rvm.io/
I was looking at replacing RVM with rbenv since I am using bundle to manage my gemfiles. rbenv, I believe, is a lot lighter in managing my Ruby versions, so I uninstalled RVM and installed rbenv. I installed the bundler gem using
gem install bundler
because we need it everywhere. Then I opened a project and installed the required version Ruby using rbenv:
rbenv install 1.9.3-p194
rbenv local 1.9.3-p194
rbenv rehash
I entered ruby -v to make sure it was using the right version of Ruby, and it was, so I tried running bundle and it ran until it tried to install RedCloth and and then failed:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb --with-cflags=-w
/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>'
It suggested that I install RedCoth before bundling, so I installed RedCloth:
gem install RedCloth
which succeeded. I then ran ruby -v, just to make sure it's still right, then tried running bundle update and the same error occured:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb --with-cflags=-w
/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/ruberto/.bundler/tmp/7551/gems/RedCloth-4.2.9 for inspection.
Results logged to /home/ruberto/.bundler/tmp/7551/gems/RedCloth-4.2.9/ext/redcloth_scan/gem_make.out
An error occurred while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
I then tried installing a different version of Ruby but had no success there either.
Does anyone have ideas?
I subsequently tried doing the same thing in my other projects and it all seems to work just fine. I have one that uses 1.8.7 and it was as easy as setting the rbenv to the right version and then running bundle. I tried almost every combination of Ruby version and yet it's not working.
I had a similar problem. It turned out that, even though I had the ~/.rbenv/shims directory at the front of my path, zsh was caching the location of bundle to /usr/local/bin/bundle.
The solution was simply running rehash at the shell (not rbenv rehash). This flushed all the cached commands, including bundle, and all went well after that.
I finally overcame the problem.
I had installed a wrong version of Ruby 1.8.7-p370. I then ran bundle and that had some gems compiling the native extensions against Ruby 1.8.7 when the bundle was for a 1.9.3 package, so even if I was to switch over to the 1.9.3 version and try running bundle again it would bomb out.
To fix this, I simply removed all the gems and then installed the right version of Ruby and then re-ran bundle.
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?
Installing the ruby1.9.1-dev package should fix this for you:
sudo apt-get install ruby1.9.1-dev