xcrun: error: invalid active developer path, problem after zsh update for flutter
xcrun: error: invalid active developer path, problem after zsh update for flutter
我将 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/
我得到了
的帮助
你必须运行sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
使用 Xcode
中的命令行工具使终端启动
似乎未设置命令行工具路径。如果你有 XCode 那么要设置你需要的路径:
- 打开XCode
- 打开首选项 (⌘,)
- 转到“位置”选项卡
- 对于“命令行工具”select 当前版本
安装 Xcode 的命令行工具以解决问题。不需要 Xcode 的完整安装。
https://developer.apple.com/download/more/?=command%20line%20tools
如果您使用的是 macOS Catalina 并希望通过 commandline/terminal 执行此操作,或者上述解决方案均无效,请尝试以下步骤:
- 禁用
SIP
(这需要通过恢复模式完成)
- 创建一个
soft simlink
链接您的“Developer”目录 (其中包含 CommandLineTools directory/instance brew
正在搜索) by 运行: 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
这是我系统上的一个例子:
- Xcode 最初位于:
/Applications/Xcode.app
- Developer 目录,包含 CommandLineTools 是:
/Library/Developer
- 运行:
sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/
- 运行:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools
- 刷新shell(或开启新实例),然后运行:
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
人提出。 他们都为我和我的客户工作,但建议 reader 谨慎行事。
我将 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/
我得到了
你必须运行sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
使用 Xcode
似乎未设置命令行工具路径。如果你有 XCode 那么要设置你需要的路径:
- 打开XCode
- 打开首选项 (⌘,)
- 转到“位置”选项卡
- 对于“命令行工具”select 当前版本
安装 Xcode 的命令行工具以解决问题。不需要 Xcode 的完整安装。 https://developer.apple.com/download/more/?=command%20line%20tools
如果您使用的是 macOS Catalina 并希望通过 commandline/terminal 执行此操作,或者上述解决方案均无效,请尝试以下步骤:
- 禁用
SIP
(这需要通过恢复模式完成) - 创建一个
soft simlink
链接您的“Developer”目录 (其中包含 CommandLineTools directory/instancebrew
正在搜索) by 运行: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
这是我系统上的一个例子:
- Xcode 最初位于:
/Applications/Xcode.app
- Developer 目录,包含 CommandLineTools 是:
/Library/Developer
- 运行:
sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/
- 运行:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools
- 刷新shell(或开启新实例),然后运行:
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
人提出。 他们都为我和我的客户工作,但建议 reader 谨慎行事。