我将 shell 更新为 zsh,当我输入 flutter --version 时,我得到了这个:
'''xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Failed to find the latest git commit date: VersionCheckError: Command exited
with code 1: git -c log.showSignature=false log -n 1 --pretty=format:%ad
--date=iso
Standard out:
Standard error: xcrun: error: invalid active developer path
(/Library/Developer/CommandLineTools), missing xcrun at:
/Library/Developer/CommandLineTools/usr/bin/xcrun
Returning 1970-01-01 01:00:00.000 instead.
Flutter 0.0.0-unknown • channel unknown • unknown source
Framework • revision () • 1970-01-01 01:00:00.000
Engine • revision b8752bbfff
Tools • Dart 2.10.2'''
我应该做什么?我不是这些事情的专家XD。
亲切的问候,
错误消息似乎与 Xcode CLI 工具有关?如果是这样,请尝试以下命令来重置它:
xcode-select --install
sudo xcode-select -s /Library/Developer/CommandLineTools/
下载最新的 Xcode 命令行工具并安装即可解决问题。不需要完整安装 Xcode。
如果您使用的是 macOS Catalina 并且想通过命令行/终端执行此操作,或者上述解决方案不起作用,请尝试以下步骤:
SIP
(这需要通过恢复模式完成)soft simlink
链接您的“Developer”目录 (其中包含 brew
正在搜索的 CommandLineTools 目录/实例),运行: sudo ln -s /path/to/Developer /path/to/Xcode.app/Contents
brew
内置的simlinker,让brew
知道CommandLineTools实例在哪里(默认情况下编写brew
是为了支持在同一目录中运行的两个实例,并且出于逻辑原因拒绝更新,他们的文档解释了这一点) ),通过运行:sudo xcode-select --switch /path/to/new/simlinked/directory/for/CommandLineTools
这是我系统上的一个示例:
/Applications/Xcode.app
/Library/Developer
sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools
brew doctor
,收到消息:Your system is ready to brew.
对于我的任何新客户,我经常会为他们的系统创建这两个别名:
alias xbandaid="sudo xcode-select --reset" #when permissions might be lacking
alias xfix="sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/ && sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools" #for the fix as described above
我将这些别名放在他们的 bash/zsh 配置文件中,在 Catalina 上,如果他们使用
.zshrc
,通常是 .zprofile
或 ZSH
,如果他们使用 .bashrc
,则通常是 .bash_profile
或 BASH
。
免责声明:虽然我已经尝试过此操作并且它已在“BigSur”客户端计算机上成功运行,但我不保证这将在这些安装上为您工作。
MacPorts
和 pkgsrc
也被称为 pkgin
,由 Joyent Software/NetBSD Samsung Group
人推出。 他们都为我的客户和我工作,但建议读者谨慎行事。
我从post
得到了帮助你必须跑
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
使用 Xcode 内的命令行工具使终端启动