Solved : Failed to install native gem like json with bundle
If you are install native gem with bundle or create a new application and got error messages like:
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/customrequire.rb:36:in`require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/customrequire.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.3for 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),andBundler cannot continue.
Make sure that gem install json -v '1.7.3'
succeeds before bundling.
This error occur because of DevKit doesn't work by the AutoRun interferes.(Please make sure you already installed DevKit. If not, just install it and your problem will be solved immediately.)
RubyInstaller team already have a perfect solution in their wiki:
Invoke the following commands in the same command prompt:
REG QUERY "HKCU\Software\Microsoft\Command Processor"
REG QUERY "HKLM\Software\Microsoft\Command Processor"
Execute each line individually. Once you run it, will see something like this:
HKEYCURRENTUSER\Software\Microsoft\Command Processor
CompletionChar REGDWORD 0x9
DefaultColor REGDWORD 0x0
EnableExtensions REGDWORD 0x1
PathCompletionChar REGDWORD 0x9
The columns of information are Key, Type and Value. If you see a key named AutoRun, there is a chance this is the culprit of the error you’re receiving.
AutoRun interferes with Ruby messing with child process executing and by result, affecting gem installation. Please remove it with the following command:
REG DELETE "HKCU\Software\Microsoft\Command Processor" /v AutoRun
Once you’re done, try opening a new command prompt and executing gem installation again.
Hope this post can solve your problem. Have a nice day!