I am getting following error while installing ruby gems. I am using Ubuntu
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 /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
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.
I just saw this link, and not sure what to do with devkit*.exe files on ubuntu.
You are missing ruby-dev or ruby-1.9-dev package as described in this stackoverflow question. Install development package files first and then trying installing the gem.
I encountered the same issue and none of these fixes worked.
Here's what worked. It seems Ubuntu's .bashrc has this line near the top:
# If not running interactively, stop here.
[ -z "$PS1" ] && return
This, as the comment suggests, stops there. Capistrano executes the commands non-interactively, so when it runs .bashrc the rest of the file never gets sourced.
I had my RVM lines below this, so the environment wasn't set up properly for capistrano to bundle.
These lines should go above the previous line:
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"
Hope this helps someone.
Related
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
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.
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.
I am trying to install Snorby (obviously) and am continuously running into errors with this same gem. Each time I attempt to do sudo bundle install in the snorby directory, I get the following error:
Installing RedCloth (4.2.9) with native extensions /usr/local/lib/site_ruby/1.9.1/rubygems/installer.rb:556:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from extconf.rb:1:in `'
I have tried everything I have seen and know. I have tried to install a previous version of it. I have tried gem upate. I have tried sudo gem install Redcloth -v . It then tells me the same continuous error. Failed to build gem native extension. Nothing is working. All help is much appreciated!
I found the issue finally! For those of you struggling, search no more. All you have to do is download the dev package by doing:
sudo apt-get install ruby1.9.1-dev
I am new to ruby on rails, I am trying to get my first project working with git and heroku. I am following the tutorial by Michael Hartl. I was originally trying to
git push heroku master
but I dont have a GemFile.lock, so I have been trying bundle installs and bundle updates but nothing works because I dont have the json native gem.
bundle update
this is the command that reuturned this error, its not the whole error i left out all the gems i already have
Installing json (1.7.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"C:/Program Files/ruby-1.9.3/bin/ruby.exe" extconf.rb
creating Makefile
make
Makefile:160: warning: overriding commands for target `C:/Program'
Makefile:153: warning: ignoring old commands for target `C:/Program'
C:/Program Files/ruby-1.9.3/bin/ruby -e "puts 'EXPORTS', 'Init_parser'" > parser-i386
mingw32.def
/bin/sh: C:/Program: No such file or directory
make: *** [parser-i386-mingw32.def] Error 127
Gem files will remain installed in C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.3 f
or inspection.
Results logged to C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/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.
If anybody knows how to fix my error so that i can move onto the next one or how i can get a working GemFile.lock, it would be appreciated.
Install json_pure instead on your development machine. This is a version of the json gem that does not require C-extensions (but is a bit slower).
On Heroku you should be able to go with the faster json directly.
If you want to build the C-extension on windows then you might want to look here:
The 'json' native gem requires installed build tools
You can create a windows-specific section in the Gemfile like so:
# Common gems
gem 'xyz'
...
# Platform specific gems
platforms :ruby do
gem 'json'
end
platforms :mswin, :mingw do
gem 'json_pure'
end
Windows isn't properly escaping the space in "C:\Program Files". I haven't used Windows in a while, but a quick search reveals a few fixes.
I had the same problem and found that in my config.yaml file, there was an installation of Ruby 1.9.2 that had a space in it. I had to uninstall that version of Ruby entirely, and remove it from the PATH in environment variables. Then, I re-installed the DevKit and it worked perfectly.