How to downgrade hugo to a previous version?

Hi there,

I was on a version 0.99 and made the mistake to upgrade to the latest version.

Now when i run anything hugo i recieve this error

exit status 128:
        fatal: 'origin' does not appear to be a git repository
        fatal: Could not read from remote repository.
        
        Please make sure you have the correct access rights
        and the repository exists.
hugo: collected modules in 1193 ms
Error: failed to download modules: failed to execute 'go [mod download]': failed to execute binary "go" with args [mod download]: go: github.com/tailwindlabs/heroicons@v1.0.6: reading github.com/tailwindlabs/heroicons/go.mod at revision v1.0.6: git ls-remote -q origin in /var/folders/ck/gvmj2pdn21zbtz8zcncfm5980000gn/T/hugo_cache/modules/filecache/modules/pkg/mod/cache/vcs/ecb0a6aab76ae32954b6d60074dbc4f5721a5fba93cb4db856ab7a22877ce2e7: exit status 128:
        fatal: 'origin' does not appear to be a git repository
        fatal: Could not read from remote repository.
        
        Please make sure you have the correct access rights
        and the repository exists.
 *errors.errorString

Now the error is tottally irrelevent as i previosuly find out unless i change the hugo version it will not be solved there have been no change on permissions or anything else.

my previous method of downgrading hugo is not working anymore which was:

  1. brew uninstall hugo
  2. brew install https://github.com/Homebrew/homebrew-core/blob/553aa577278e74b4d440e3a0ae485bdd73f157f8/Formula/hugo.rb

As it has been a while since i took the painfull path of downgrading hugo. Does anyone have an idea of a working solution to downgrade hugo to version 0.99

Thanks for taking the time to help

Probably there is a better solution, but this worked for me yesterday:

  1. Find a suitable hugo version on the Hugo releases page
  2. Download and unpack the appropriate file for your platform to a suitable directory
  3. Use that in your commands (for example, use ~/hugo serve, or add it to the path, or add an alias, …)
  4. Since you are on Mac, it will probably complain that it cannot verify the developer of the binary, in this case locate the file in Finder, CTRL+click on it, and click Open to add it to the exceptions.

Are you sure that you only upgrade hugo ?

Sounds like your repository changed too.

Hi @divinerites

This is related to hugo version upgrade had the smae issue in past where it show randon messages but once i downgrade or upgrade from a specific version everthing works. So to answer your question there is no change at all in the repository.

The hugo version downgrade isnt that easy for example running brew install go@1.18 instal golang vesion 1.18 but the same technique doesnt work for hugo

brew install hugo@0.102.0
Warning: No available formula with the name "hugo@0.102.0".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> 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.

So i dont know what the issue is maybe the hugo versions with the homebrew doesnt matchup?

i can install any brew package to a specific version including golang but hugo fails.

TLDR: Use something other than Homebrew

Only a few of the Homebrew packages have version-specific formulae. See this list. Go, for example, has version-specific formulae, but Git does not.

If someone had the time and inclination, they could submit version-specific formulae for Hugo, but those formulae are subject to these restrictions. Most notably:

Versioned formulae should differ in major/minor (not patch) versions from the current stable release

That means that we could have formulae for v0.101.0 and v0.102.0, but not for v0.102.1, v0.102.2, or v0.102.3.

I agree.

The current version of Homebrew is v3.6.0. The switch command was removed in v2.6.0. Prior to v2.6.0, provided you had not run brew cleanup, you could easily revert to an earlier installation with something like:

brew switch hugo 0.102.1

But you can’t do that anymore.

I spent far too much time researching methods to install a specific version via Homebrew when the package does not have version-specific formulae. This looked promising, but threw an error.

This is the best method that I can find so far:

  1. Uninstall the current version with brew uninstall hugo
  2. Visit https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/hugo.rb
  3. Click the “History” link
  4. Find the “bottle” commit for the desired version (example: hugo: update 0.99.1 bottle)
  5. Press the “View at this point in history” button
  6. Press the “Raw” button
  7. Right-click anywhere on the page and choose “Save as…”
  8. Save hugo.rb to any directory (home, downloads, etc.)
  9. Open a terminal
  10. CD into the directory where you saved the hugo.rb file
  11. Install with brew install hugo.rb
  12. Prevent automatic updates with brew pin hugo

Compare that with building from source:

# Install the latest version
go install -tags extended github.com/gohugoio/hugo@latest
# Downgrade to something else
go install -tags extended github.com/gohugoio/hugo@v0.100.1

The first time you build from source, it will take a minute or two as Go primes the module cache. Subsequent builds will generally be much faster.

7 Likes

Hi @jmooring

Thanks again for such a detailed response and for providing the solution. I was able to install the previous version using brew install hugo.rb.

If hugo creates a page or link where one can support the development of hugo to be added to homebrew list of version specific so i can install using brew install hugo@0.102.0 please update this post.

Thank you again for great support.

Another restriction for versioned Homebrew formulae:

No more than five versions of a formula (including the main one) will be supported at any given time.

So, as of today, we could only have these formulae.

  • latest (v0.102.3)
  • v0.102.0
  • v0.101.0
  • v0.100.0
  • v0.99.0

That means you would not be able to install:

  • v0.102.2
  • v0.102.1
  • v0.100.2
  • v0.100.1
  • v0.99.1
  • v0.98.0
  • etc.

Given this restriction, I don’t think it’s worth the effort to create and maintain multiple formulae.

1 Like

Maybe it’s a matter of people who know vs people who don’t know, but I can’t imagine using any other installation method beyond downloading the zip, unzipping it into the specific folder, adding that folder to the system path, and moving on with life. Then upgrading or downgrading is a simple matter of overwriting the file. (or as extra credit, just appending the version number to the executable so when you run it you run the version you desire)

1 Like

Hi @gaetawoo

  1. Seems like you are not using mac as installing directly doest work on mac even if you whitelist hugo as developer.
  2. using a package manager is the easiest option to manage multiple tools like hugo for example golang
  3. your method doesnt seems easy even as you explain comparing to a single command brew install hugo

But that is a preference, not people who know vs who dont know. Even the senior developers i have are using package manager not because they dont know how to install directly.

Thanks

Hi @jmooring

Thanks i didnt knew this restriction.

Your point is well taken. I had not even considered that Mac operating system wouldn’t allow that. And yes, it would be technically easier to have a single click install from a store or repository. But in my view, the beauty that hugo is a single binary it can just be itself, no install or uninstall crumbs in registry.

1 Like

As was pointed out in

It is possible to install directly on the Mac, but yes, the Mac makes it annoyingly difficult to install Hugo directly.

For most users it’s trivial to install Hugo directly.

Apple, from my understanding, is not exactly welcoming to open source projects like Hugo and Go, and many others, and third party tools are required for a decent experience when using open source.

I don’t think that is going to change any time soon, and since the issue is really with imposed limitations by Apple and/or Homebrew, they are the ones you need to raise an issue with for a change that doesn’t put ridiculous amounts of work on individual developers or projects. YMMV.

1 Like