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

5

38

I'm trying to take a stab at a new site using Hugo, and I am stuck during installation. I've installed Homebrew and when running the version, I get the following:

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

And when I run brew install hugo

I get the following:

~ % 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.

What am I doing wrong? This is the first time working in home-brew.


Edit: when running brew install --verbose Hugo, I get the following warnings:

% 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

Amr answered 7/1, 2021 at 0:57 Comment(2)
Try brew doctor?Mccool
I get a few warnings but no errors. Updated question to reflect.Amr
C
170

Use

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

or

git -C $(brew --repository homebrew/core) reset --hard HEAD
Charlotte answered 17/1, 2021 at 10:53 Comment(5)
If the checkout master is raising some errors, you might need to explicitly specify the remote (ex. origin), as in git -C $(brew --repository homebrew/core) checkout origin/master. Use git remote -v to get the remote name. See this for why: #1783905Chipman
It was useful for me, thank @Gino MempinEndurance
Confirmed this worked for M1 Macbook Air.Phycomycete
It works on macbook pro 2021. THANK YOUScrounge
This works. Can I get any explanation on this answer ? What did it do? thanks!Carbonation
K
4

As illustrated by this thread, this might be related to brew itself, not so much hugo.

brew install --verbose hugo

This should give you more and allow you to see at which step brew is stuck.

[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".

That points to a brew configuration issue, since there is a formulae for hugo

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

Check that Formula folder and see if hugo is missing there.
If not, at least try brew extract hugo inside a new tap.

brew tap-new gohugoio/hugo
brew extract --version 0.80.0 hugo gohugoio/hugo
brew install gohugoio/hugo/[email protected]
Klement answered 7/1, 2021 at 1:24 Comment(0)
F
3

Set your core by running the below two commands

  1. rm -rf $(brew --repo homebrew/core)
  2. brew tap homebrew/core
Fairleigh answered 24/8, 2021 at 22:17 Comment(0)
D
3

I got the same error. I tried most solutions above. In the end these steps helped:

uninstall homebrew

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

manually delete this file and the two folders

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

/usr/local/Homebrew

/usr/var/homebrew

install homebrew again

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

Deweydewhirst answered 19/10, 2021 at 15:52 Comment(0)
B
0

run brew doctor

and the output:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Homebrew/homebrew-core was not tapped properly! Run:
  rm -rf "/opt/homebrew/Library/Taps/homebrew/homebrew-core"
  brew tap homebrew/core

Warning: Some taps are not on the default git origin branch and may not receive
updates. If this is a surprise to you, check out the default branch with:
  git -C $(brew --repo homebrew/core) checkout master

follow the instruction which under the warning, everything seems resolved.

Benedetta answered 19/12, 2022 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.