优胜美地升级破坏了ruby.h

自从升级到Yosemite后,我在尝试构建包含ruby.h任何内容时遇到此错误:

 In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby.h:33: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found #include "ruby/config.h" ^ 1 error generated. make[1]: *** [objects/if_ruby.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [first] Error 2 

当然,/ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h确实缺少/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h

 $ ls -laF /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ total 72 drwxr-xr-x 21 root wheel 714 Jul 29 21:56 ./ drwxr-xr-x 5 root wheel 170 Jul 29 21:56 ../ drwxr-xr-x 7 root wheel 238 Jul 29 21:56 backward/ -rw-r--r-- 2 root wheel 3360 Sep 21 15:25 debug.h -rw-r--r-- 2 root wheel 5553 Sep 21 15:25 defines.h -rw-r--r-- 2 root wheel 881 Sep 21 15:25 digest.h -rw-r--r-- 2 root wheel 7628 Sep 21 15:25 dl.h -rw-r--r-- 2 root wheel 14123 Sep 21 15:25 encoding.h -rw-r--r-- 2 root wheel 32904 Sep 21 15:25 intern.h -rw-r--r-- 2 root wheel 5869 Sep 21 15:25 io.h -rw-r--r-- 2 root wheel 4522 Sep 21 15:25 missing.h -rw-r--r-- 2 root wheel 37617 Sep 21 15:25 oniguruma.h -rw-r--r-- 2 root wheel 1502 Sep 21 15:25 re.h -rw-r--r-- 2 root wheel 890 Sep 21 15:25 regex.h -rw-r--r-- 2 root wheel 49734 Sep 21 15:25 ruby.h -rw-r--r-- 2 root wheel 4651 Sep 21 15:25 st.h -rw-r--r-- 2 root wheel 374 Sep 21 15:25 subst.h -rw-r--r-- 2 root wheel 1102 Sep 21 15:25 thread.h -rw-r--r-- 2 root wheel 2139 Sep 21 15:25 util.h -rw-r--r-- 2 root wheel 1968 Sep 21 15:25 version.h -rw-r--r-- 2 root wheel 1794 Sep 21 15:25 vm.h 

安装是否意外成了文件? Yosemite是否只附带了破坏的Ruby头文件集?

解决这个问题的最佳方法是什么? 我可以在那里解压缩源代码以获得正确的标题吗?

有一点需要注意:升级到“OS X El Capitan”后我遇到了这个问题。 我通过运行’xcode-select –install’安装了命令行工具。 在那之后,我的ruby构建环境再次开始工作。

我得到了同样的错误,但安装了“ 命令行工具(OS X 10.10)for Xcode – Xcode 6.1 ”,安装工作正常。

 cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby sudo ln -s ../universal-darwin15/ruby/config.h ./config.h 

更新Nicholas Tsipanov在2014-10-18的回答。

如果你使用Homebrew, brew install ruby是一个快速的解决方法(它为你提供了一个与Xcode不同的全新ruby安装)。

试试这个:

 cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby sudo ln -s ../universal-darwin13/ruby/config.h ./config.h 

不知怎的,Xcode在升级中搞砸了。

我打开了Xcode(我从来没有这样做过),它抱怨各种各样的缺失组件。 所以我让它继续前进并自我修复,现在一切都很顺利。

在关于OP的评论中向CDub道具,指出这是一个奇怪的潜在来源。

通过指向Xcode开发人员工具的正确路径来修复。

之前出错(注意Xcode711.app而不是Xcode.app的路径)

 /Applications/Xcode711.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:24:10: 

 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 

对于已经从Apple开发人员站点安装了Xcode的用户,运行xcode-select --install不起作用,因为它会说Xcode已经安装(Xcode已经捆绑了CommandLineTools )。

在我的例子中,我通过从同一个地方下载相应的CommandLineTools ,执行它,然后转到/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg并执行它来修复它。