When I execute the command:
$ sudo gem install rails
I receive the error below. How do I resolve this?
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb
mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in
/Library/Ruby/Gems/1.8/gems/json-1.6.6 for inspection.
Results logged to
/Library/Ruby/Gems/1.8/gems/json-1.6.6/ext/json/ext/generator/gem_make.out
Benjamins-MacBook-Air:~ benrweiss$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb
mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in
/Library/Ruby/Gems/1.8/gems/json-1.6.6 for inspection.
Results logged to
/Library/Ruby/Gems/1.8/gems/json-1.6.6/ext/json/ext/generator/gem_make.out
I too faced the same issue. I have installed the Ruby 1.9.3.
When i tried to create a new rails application, it throws the following
error.
Installing json (1.6.6) with native extensions The system cannot find
the path specified.
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:551:in `rescue
in block in build_extensions': ERROR: Failed to build gem native
extension. (Gem::Installer::ExtensionBuildError)
Gem files will remain installed in
C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.6.
6 for inspection.
Results logged to
C:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.6.6/ext/json/ext/ge
nerator/gem_make.out
from
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:529:in `b
lock in build_extensions'
from
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:504:in `e
ach'
from
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:504:in `b
uild_extensions'
from
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `i
nstall'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/sour
ce.rb:101:in `block in install'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/ruby
gems_integration.rb:78:in `preserve_paths'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/sour
ce.rb:91:in `install'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/inst
aller.rb:58:in `block (2 levels) in run'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/ruby
gems_integration.rb:93:in `with_build_args'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/inst
aller.rb:57:in `block in run'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/spec
_set.rb:12:in `block in each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/spec
_set.rb:12:in `each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/spec
_set.rb:12:in `each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/inst
aller.rb:49:in `run'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/inst
aller.rb:8:in `install'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/cli.
rb:222:in `install'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/vend
or/thor/task.rb:22:in `run'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/vend
or/thor/invocation.rb:118:in `invoke_task'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/vend
or/thor.rb:246:in `dispatch'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/vend
or/thor/base.rb:389:in `start'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/bin/bundle:13:in
`<top (required)>'
from C:/Ruby192/bin/bundle:19:in `load'
from C:/Ruby192/bin/bundle:19:in `<main>'
After i searched in Google i found that, there is some issue( https://github.com/carlhuda/bundler/issues/1809) with json 1.6.6.
So i update the gem file with, gem 'json', '1.6.5' and i am able to
solve this error.
Hopefully this will help you to solve this problem.
You just try to install the json 1.6.5 seperately and this problem will
get solved.