开发者问题收集

Brew 安装 - 不是有效的引用错误

2022-01-03
3384

我尝试使用单行命令在 macos m1 芯片上安装 homebrew,但一直遇到以下错误。有人能帮我解决这个问题吗?谢谢。

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew

Press RETURN to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R miththinda:admin /opt/homebrew
==> Downloading and installing Homebrew...
HEAD is now at a0ae4a7a0 Merge pull request #12658 from sjackman/sj/linkage-checker
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
3个回答

删除目录并尝试重新安装对我有用。

sudo rm -rf /opt/homebrew
jkndmiththinda
2022-01-03

请在您的终端中运行以下命令:

rm -fr $(brew --repo homebrew/core)  # because you can't `brew untap homebrew/core`
brew tap homebrew/core

您可以在 此处 查看问题的详细信息。

Zubair Hassan
2022-04-07

Mac 上也遇到了类似的问题,我首先通过输入以下命令将其卸载,然后安装了 Xcode,再次运行 install 命令后,它就可以正常工作了。

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Malvin Nyahwai
2022-01-17