问题描述
我将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/
,
如果您使用的是 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
这是我系统上的示例:
- 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
或 {{1 }} 如果他们使用 .bash_profile
。
免责声明:虽然我已经尝试过这个并且它已经成功地在“BigSur”客户端机器上运行,但我不保证这将适用于这些安装。 BASH
和 MacPorts
也称为 pkgsrc
,由 pkgin
人推出。 他们都为我和我的客户工作,但建议读者自行决定。
我在post
的帮助下您必须运行/* I have an array of data field names and type of conversion that should be made for that field,* I loop through each of the fields that need to be converted and based on a converter type conversion
* changes the value of that field.
*/
foreach ($convertFields as $field=>$type){
if(isset($this->converters[$type])) {
$data[$field] = $this->converters[$type]->convert($data[$field]);
}else {
throw new \Exception("Converter type `".$type."`` doesn't exist");
}
}
使终端开始使用Xcode内的命令行工具
好像没有设置CLI工具路径。 如果您拥有XCODE,则需要设置路径
- 转到Xcode中的首选项
- 转到“位置”标签
- 从下拉菜单中选择命令行工具版本
安装 Xcode 的命令行工具来解决问题。不需要完全安装 Xcode。 https://developer.apple.com/download/more/?=command%20line%20tools