无法使用 Xcode 10 在 Mojave 上安装 brew

Cannot install brew on Mojave with Xcode 10

我无法在我的 mac 上安装任何 brew 软件包,并出现以下错误信息。

安装在我的 Mac:

输入 brew install xxx。输出为:

Error: Your Xcode (9.3) is too outdated.
Please update to Xcode 10.0 (or delete it).
Xcode can be updated from
https://developer.apple.com/download/more/

Error: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install

但是当我输入 xcode-select --install 时,它说它不可用
Xcode select install error

我的 Mac 上 Xcode 的两个版本的路径:

/Applications/Xcode-beta.app
/Applications/Xcode.app

我的配置输出:
xcode-select-p

/Applications/Xcode.app/Contents/Developer     

酿造配置

HOMEBREW_VERSION: 1.6.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: 22e9fd772926e389e264cfb328c3d810b06759f9
Last commit: 5 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 854bb90b366169915849fc9a83e941b8883cea1f
Core tap last commit: 6 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.6 =>./System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.1 build 902
Git: 2.15.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_131
macOS: 10.14-x86_64
CLT: N/A
Xcode: 9.3
XQuartz: N/A

目前,Brew 不支持 macOS Mojave Beta。

(输入 brew doctor 以确认他们尚未接受 Mojave 的问题)

参见:https://apple.stackexchange.com/questions/327458/install-homebrew-packages-on-macos-mojave-beta

参见:https://github.com/Homebrew/brew/issues/4295

您需要从 https://developer.apple.com/download/ ANDXcode 10 Beta 的命令行工具 (macOS 10.14)" 来自

https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_macOS_10.14_for_Xcode_10/Command_Line_Tools_macOS_10.14_for_Xcode_10.dmg

其他评论贡献的更新,安装后"Command Line Tools",您还需要在终端中执行以下命令。

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

我能够通过在此处手动下载命令行工具在 Mojave 上安装 Homebrew:https://developer.apple.com/download/more/

在此处修改 Homebrew 安装脚本:https://raw.githubusercontent.com/Homebrew/install/master/install

通过替换:

def should_install_command_line_tools?
  return false if force_curl?
  return false if macos_version < "10.9"
  !File.exist?("/Library/Developer/CommandLineTools/usr/bin/git") ||
  !File.exist?("/usr/include/iconv.h")
end

有了这个:

def should_install_command_line_tools?
  return true
end

然后执行脚本即可。

这有点 hacky,但它对我有用,可以帮助处于测试阶段的人。

安装 Xcode 10 Beta Xcode 10 Beta 的命令行工具 (macOS 10.14) 后,我还更改了 xcode-select 的路径以使用新安装的命令行工具:

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

确认 10.14 的命令行工具不会创建 /usr/include/ 使 brew 安装脚本坚持重新下载和安装 CL 的文件夹。

下载脚本,手动删除检查工作正常。 (注意它应该是 false 而不是 true.

def should_install_command_line_tools?
  return **false**
end

从 10.14 开始,需要一个新步骤来创建 /usr/include 中的头文件:

安装/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

来源:The Xcode 10 release notes

安装CLT后,你可以要求CLT添加头文件到/usr/include,然后homebrew会适当检测命令行工具。

installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /