为什么 Homebrew 报告 "couldn't understand kern.osversion `14.0.0'"?

Why does Homebrew report "couldn't understand kern.osversion `14.0.0'"?

当我运行brew -- config我得到

HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: bc071fb5448628aea8f066bbc0f37b0ecb4f11ee
Last commit: 16 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit haswell
OS X: 10.10.1-x86_64
Xcode: 6.1.1
CLT: 6.1.1.0.1.1416017670
couldn't understand kern.osversion `14.0.0'
GCC-4.2: build 5666
Clang: 6.0 build 600
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby

尽管我的 Xcode(在 Yosemite 上)命令行工具似乎是最新的(确保我重新 运行 xcode-select --install)并且在正确的地点

/Applications/Xcode.app/Contents/Developer 

根据 xcode-select -print-path,我的(仅)gcc

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

根据 brew doctor 的唯一问题是

Unexpected static libraries:
    /usr/local/lib/libtclstub8.6.a
    /usr/local/lib/libtkstub8.6.a

但是我发现了一些可疑的事情,特别是 usr/bin/gcc-4.2--version 给出了

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
...

/usr/bin/i686-apple-darwin11-gcc-4.2.1,其中--version也给出

couldn't understand kern.osversion `14.0.0'
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)    
...

brew -- config

的报告是什么

couldn't understand kern.osversion `14.0.0'

是什么意思?有什么我应该做的吗?

你之前有没有在这台机器上升级 OS X?我猜它们来自较旧的安装。由于默认情况下未安装 gcc,因此 OS 升级可能不会删除或替换 gcc 和其他 XCode 命令行工具。您是否真的可以安全地删除它们,我不知道,但显而易见的事情是重命名它们(或将它们移动到备份子目录中),以便它们不在您的 PATH 中。这样,自制软件就不会找到它们并使用更新的编译器 (clang)。您的系统(XCode、brew)很可能会照常运行,因为它们会使用在您的系统上找到的 clang

您看到的错误 "couldn't understand kern.osversion '14.0.0'" 很可能是因为此 gcc 是针对较旧的 OS X 内核版本编译的,而当前版本(Yosemite/14.0.0) 向后不兼容。

我不确切知道安装了哪些编译器工具,但对于有问题的 gcc,您可以这样做:

mv /usr/bin/gcc-4.2 /usr/bin/gcc-4.2-oldOSX10.9

(假设这是在 10.9 上安装的;可能在更早的版本上)。

有点不幸的是 XCode 的升级(或者更确切地说,一个全新的版本)不检查旧版本的命令行工具并删除那些 (*)。尽管可以理解,Apple 当然假定您不使用常规 XCode 工具之外的任何东西;他们显然不会以这种方式支持自制软件。

(*) 也许是这样,但如果您跳过一个或两个版本,它可能不会及时返回那么久以检查旧版本。