2012-06-01 116 views
4

在OS X Lion中試圖啓動Rails服務器出現錯誤`build_extensions':錯誤:無法構建gem本機擴展。 (寶石::安裝:: ExtensionBuildError)

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

如果我再運行

bundle install json 

我收到以下錯誤時,

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 

我在nokogiri - ERROR: Failed to build gem native extension上看到了答案,但是我已經運行了Xcode 4.3.2。

任何想法?謝謝

+1

你錯過了Ruby開發人員頭文件'locate ruby​​.h'?請閱讀本主題中的所有回覆:http://www.ruby-forum.com/topic/191688 ..它應該可以幫助你,如果它確實請在這裏發佈解決方案。 – Casper

回答

6

對於OS 10.7 + XCode4.3只打開Xcode首選項,選擇 「下載」按鈕,選擇下載的「組件」選項卡,突出顯示 「命令行工具」,然後按安裝按鈕。

相關問題