尝试通过 Homebrew 安装 Hugo - "Could Not Resolve HEAD to a Revision"

Trying to install Hugo via Homebrew - "Could Not Resolve HEAD to a Revision"

我正在尝试使用 Hugo 尝试一个新站点,但在安装过程中卡住了。我已经安装了 Homebrew,当 运行 更新版本时,我得到以下信息:

~ % brew --version
Homebrew 2.7.2
Homebrew/homebrew-core (no git repository)
Homebrew/homebrew-cask (git revision b96680c; last commit 2021-01-07)

而当我 运行 brew install hugo

我得到以下信息:

~ % brew install hugo
fatal: Could not resolve HEAD to a revision
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "hugo".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

我做错了什么?这是第一次在家酿工作。


编辑:当 运行ning brew install --verbose Hugo 时,我收到以下警告:

% brew install --verbose hugo

fatal: Could not resolve HEAD to a revision

==> Searching for similarly named formulae...

Error: No similarly named formulae found.

Error: No available formula or cask with the name "hugo".

==> Searching for a previously deleted formula (in the last month)...

Error: No previously deleted formula found.

==> Searching taps on GitHub...

/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/2.7.2\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.1\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location https://api.github.com/search/code\?q=user\%3AHomebrew\+path\%3AFormula\+path\%3ACasks\+path\%3A.\+filename\%3Ahugo\+extension\%3Arb\&per_page=100 --header Accept:\ application/vnd.github.v3\+json --write-out '
'\%\{http_code\} --header Accept:\ application/vnd.github.antiope-preview\+json --header Authorization:\ token\ ****** --dump-header /private/tmp/github_api_headers20210106-8376-1r02uaz

this thread 所示,这可能与 brew 本身有关,而不是 hugo

brew install --verbose hugo

这应该会给你更多信息,让你看到 brew 卡在哪一步。

[where the error occurred], I changed into that directory to find that it was empty – all that was in the dir was a .git/ folder and nothing else.

So, to restore the missing contents, I used git fetch and git pull --rebase.


No available formula or cask with the name "hugo".

这表明存在 brew 配置问题,因为存在 formulae for hugo

Packages are installed according to their formulae, which live in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula

检查 Formula 文件夹并查看是否缺少 hugo
如果没有,至少在 .

中尝试 brew extract hugo
brew tap-new gohugoio/hugo
brew extract --version 0.80.0 hugo gohugoio/hugo
brew install gohugoio/hugo/hugo@0.80.0

使用

git -C $(brew --repository homebrew/core) checkout master

git -C $(brew --repository homebrew/core) reset --hard HEAD

通过运行以下两个命令设置您的核心

  1. rm -rf $(brew --repo homebrew/core)
  2. 酿造水龙头homebrew/core

我遇到了同样的错误。我尝试了上面的大多数解决方案。最后,这些步骤有所帮助:

卸载自制软件

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

手动删除这个文件和两个文件夹

/usr/local/com.apple.installer.keep

/usr/local/Homebrew

/usr/var/homebrew

再次安装自制软件

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"