mac下使用Homebrew安装nginx报错

mac下安装nginx

安装命令:$ brew install nginx

安装时报如下错误:

Updating Homebrew...
error: Not a valid ref: refs/remotes/origin/master
Error: No available formula with the name "nginx" 
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

修复Homebrew

修改清华源命令:

cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

执行以上命令,继续报错:

$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

据查以上报错是git运行需要一个xcode插件,执行以下命令:

xcode-select --install

等待1~2min后,插件安装完成,重新执行修改源为清华源的命令,无报错。

执行brew update

执行brew update命令,报错:

$ brew update
error: Not a valid ref: refs/remotes/origin/master
fatal: Could not resolve HEAD to a revision
Already up-to-date.

查找以上error解决方法,执行brew update --verbose,结果如下:

$ brew update --verbose
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Updating /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

Updating /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
fatal: Could not resolve HEAD to a revision

Already up-to-date.

更加以上报错,可知报错路径为: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

打开该路径:

cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
$ ls -al
total 0
drwxr-xr-x   3 zuige  admin   96  7 11 00:21 .
drwxr-xr-x   3 zuige  admin   96  7 11 02:15 ..
drwxr-xr-x  12 zuige  admin  384  7 18 01:03 .git

发现只有一个.git文件
在该路径下执行:

$ git fetch --prune origin
$ git pull --rebase origin master
From https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core
 * branch                  master     -> FETCH_HEAD
Updating files: 100% (5370/5370), done.

再次执行brew update,更新成功。

$ brew update
Already up-to-date.

安装nginx

再次执行安装nginx命令,安装成功。

$ brew install nginx
  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值