`build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

别来无恙 提交于 2019-12-10 16:06:12

问题


On OS X Lion when trying to start the rails server I get the error

Could not find json-1.5.4 in any of the sources
Run `bundle install` to install missing gems.

If I then run

bundle install json

I get the following errors

Installing json (1.5.4) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:556:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /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 /Applications/RubyApps/skatemyspot/json/ruby/1.8/gems/json-1.5.4 for inspection.
Results logged to /Applications/RubyApps/skatemyspot/json/ruby/1.8/gems/json-1.5.4/ext/json/ext/parser/gem_make.out
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:509:in `each'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:509:in `build_extensions'
    from /Library/Ruby/Site/1.8/rubygems/installer.rb:180:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/source.rb:101:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:78:in `preserve_paths'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/source.rb:91:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/installer.rb:58:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:93:in `with_build_args'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/installer.rb:57:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/installer.rb:49:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/installer.rb:8:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/cli.rb:220:in `install'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/vendor/thor/task.rb:22:in `send'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.18/bin/bundle:13
    from /usr/bin/bundle:19:in `load'
    from /usr/bin/bundle:19

I've seen the answer at nokogiri - ERROR: Failed to build gem native extension but I have Xcode 4.3.2 running.

Any ideas? Thanks


回答1:


For OS 10.7 + XCode4.3 only open Xcode preferences, select the "Downloads" button, select the "Components" tab of Downloads, highlight "Command Line Tools" and press the install button.



来源:https://stackoverflow.com/questions/10856460/build-extensions-error-failed-to-build-gem-native-extension-geminstaller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!