当前位置:   article > 正文

Homebrew安装失败解决方法_“安装homebrew 失败的解决方案”

“安装homebrew 失败的解决方案”

title: Homebrew安装失败解决方法
tags: Mac, Homebrew


出现问题

首先我们执行了官方命令

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

然后输入任意键的时候出现错误:

xcode-select: error: invalid developer directory ‘/Library/Developer/CommandLineTools’
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

我们根据错误可以看出来是因为没有 /Library/Developer/CommandLineTools 这个目录

解决问题

方法1. 重新安装Tools

使用命令安装Tools
xcode-select --install

注意:有时候执行这个命令会出现错误 :不能下载该软件,因为网络出现问题。
这时候我们可以在 https://developer.apple.com/download/more/ 上面手动下载安装Command_Line_Tools

安装好tools后我们再次执行官方命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

成功安装

方法2.修改安装脚本文件

我们首先用命令查看本地tools的位置
xcode-select -p

一般会得到/Applications/Xcode.app/Contents/Developer

接着下载官方脚本https://raw.githubusercontent.com/Homebrew/install/master/install 并保存为 install.sh文件

把文件中的/Library/Developer/CommandLineTools 替换成你刚刚得到的路径/Applications/Xcode.app/Contents/Developer并保存

最后使用命令执行脚本
/usr/bin/ruby -e "$(cat install.sh)"

注意: install.sh 要CD到你存放的路径来执行
或者直接指明路径,如/usr/bin/ruby -e "$(cat /Users/clown/Downloads/install.sh)"

成功安装

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/401339
推荐阅读
相关标签
  

闽ICP备14008679号