无法在搭载Xcode 10的Mojave上安装brew

24

我在我的Mac上无法安装任何brew包,错误信息如下。

已安装:

  • macOS 10.14 Beta (18A293u)
  • Xcode 9.3 (9E145)
  • Xcode 10.0 beta (10L176w)

输入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选择安装错误

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

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

以下是我的配置输出:
xcode-select -p

/Applications/Xcode.app/Contents/Developer     

brew config

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

2
因为提问得非常好,所以我点了赞,但同时也投了关闭票,因为这个问题应该在AskDifferent或SuperUser上提出。 - matt
今天早些时候我遇到了同样的问题。通过从developer.apple.com下载CL工具并运行CLTools_SDK和CLTools_Executables解决了这个问题。 - Philippos Slicher
7个回答

24

我正在使用 Xcode 10.0 beta 3(在 macOS 10.14 上),但是 beta 3 版本没有可用的命令行工具。 - CopsOnRoad

20

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

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

来源:Xcode 10 发布说明


就是这样。干杯! - Bruno Muniz

9
安装完CLT后,您可以要求CLT将头文件添加到/usr/include中,然后Homebrew会适当地检测到命令行工具。
installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

3
安装完 Xcode 10 Beta适用于 Xcode 10 Beta 的 macOS 10.14 的命令行工具 后,我还通过以下命令更改了 xcode-select 的路径,以使用新安装的命令行工具:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer     

1

0

我成功地在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,但对我很有效,在beta期间可能会帮助某些人。


我没有尝试黑客方式,但安装CLTools有效。非常感谢。不幸的是,我仍然无法安装我的brew软件包,例如brew install octave。它显示错误信息:Error: You are using macOS 10.14. We do not provide support for this pre-release version. You may encounter build failures or other breakages. Please create pull-requests instead of filing issues. - Weslie
这个答案指引了我正确的方向,但是,我手动安装了Xcode Beta 2和相关的命令行工具后,我更新了上面的代码块以return false而不是return true(因为你已经安装了命令行工具,所以brew不需要再次安装)。然后我成功地安装了homebrew,并且使用brew安装软件包也正常工作。 - Erve1879
您可以通过安装 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg 来避免修改脚本。 - craig65535

-1

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

下载脚本,手动移除检查可以正常工作。(请注意,它应该是false而不是true。)

def should_install_command_line_tools?
  return **false**
end

你可以通过安装 /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg 来创建 /usr/include 中的头文件。 - craig65535
是的,我们昨天也找到了同样的解决方案。谢谢@craig65535。 - Irvin Chen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接