I noticed that a new version of k9s
became available, so I updated it.
brew update && brew upgrage k9s
Unfortunately, after the update, k9s
could not connect anymore.
Everything was ok, vpn up, login on aws ok, and also kubectl
worked perfectly.
I checked everything, but it did not work.
Ok: let’s not waste time and revert the package…
It looks like reverting a package is not an easy task on brew. I found lots of different instructions online, but none worked. So… here’s another set of instructions: mine 😁
Brew: how to revert to an old version of a formula
Find the repository info
brew info k9s
The output will be something like this
k9s: stable 0.25.21 (bottled), HEAD
Kubernetes CLI To Manage Your Clusters In Style!
https://k9scli.io/
/opt/homebrew/Cellar/k9s/0.25.21 (9 files, 65.4MB) *
Poured from bottle on 2022-07-06 at 18:28:01
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/k9s.rb
License: Apache-2.0
==> Dependencies
Build: go ✘
==> Options
--HEAD
Install HEAD version
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Analytics
install: 18,119 (30 days), 30,923 (90 days), 144,819 (365 days)
install-on-request: 18,053 (30 days), 30,783 (90 days), 144,304 (365 days)
build-error: 2 (30 days)
Open the link (https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/k9s.rb
) in a browser,
then browse the file’s history, and find your previous version.
In my case, I picked https://github.com/Homebrew/homebrew-core/blob/4ff8fd9d3937bfcc8bfc6388a6cdb9fb5bdd6f5a/Formula/k9s.rb
Download the file locally (eg. to ./k9s.rb
) and install it manually:
brew install k9s.rb
It complained a bit, but it worked:
Error: Failed to load cask: k9s.rb
Cask 'k9s' is unreadable: wrong constant name #<Class:0x000000010f905eb0>
Warning: Treating k9s.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/k9s/manifests/0.25.18
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/k9s/blobs/sha256:fabed8c642a6242e1e169b774f450c3a1206efdbd4b8dba6927ff73db8c65135
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fabed8c642a6242e1e169b774f450c3a1206efdbd4b8dba6927ff73db8c65135?se=2022-07-07T05%3A30%3A00Z&sig=waT0cM43eRi8JpxjYDaQTVIEnQ7355LTb45mqbsUlFc%3D&
######################################################################## 100.0%
Warning: k9s 0.25.21 is available and more recent than version 0.25.18.
==> Pouring k9s--0.25.18.arm64_monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/k9s/0.25.18: 9 files, 63.9MB
==> Running `brew cleanup k9s`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/ar/Library/Caches/Homebrew/k9s--0.25.18... (16.7MB)
…and eventually I got back a version of k9s
that worked well again.
What did NOT work
The @version
brew install k9s@v0.25.18
This normally works… but in k9s
case it did not because there is only the k9s formula without options.
Compare these two results:
brew search openjdk
==> Formulae
openjdk ✔ openjdk@11 ✔ openjdk@17 ✔ openjdk@8 openj9 openvdb
==> Casks
adoptopenjdk microsoft-openjdk openkey
adoptopenjdk8 ✔ microsoft-openjdk11
vs
brew search k9s
==> Formulae
k9s ✔
openjdk
supports @11
, @17
, and @8
, while k9s
does not have alternatives.
From Git History
Some websites suggest to compose a url mixing the url from brew info
(the one I used) + the commit id that can be found with brew log <formula>
.
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/k9s.rb
+ 4ff8fd9d3937bfcc8bfc6388a6cdb9fb5bdd6f5a
= https://github.com/Homebrew/homebrew-core/blob/4ff8fd9d3937bfcc8bfc6388a6cdb9fb5bdd6f5a/Formula/k9s.rb
Then calling brew install <url>
should work
brew install https://github.com/Homebrew/homebrew-core/blob/4ff8fd9d3937bfcc8bfc6388a6cdb9fb5bdd6f5a/Formula/k9s.rb
I tried also different urls, but this method never worked for me. The best result was this error:
Error: Non-checksummed download of k9s formula file from an arbitrary URL is unsupported!
`brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead
Obsolete versions of brew
Somewhere I found instructions using the version
command, but it does not exist (anymore?)
brew versions
Error: Unknown command: versions
The switch command
brew switch <formula> <version>
This may work, but only if you have multiple versions installed (and it was not my case)
The “it may work, but maybe another time…”
I found out that it’s quite easy to create custom repositories (taps!) for Brew. It’s just a lot of extra work for something like reverting a package that should be daily routine.