Install exact version via brew

Table of Contents

For instance, we’re looking for kubernetes-helm@2.9

helm 2.9

git -C "$(brew --repo homebrew/core)" fetch --unshallow
cd "$(brew --repo homebrew/core)"
git log Formula/kubernetes-helm.rb
# searching for 2.9.0 with a command /2\.9\.0 and copying hash like "7ade79f13b4bbcc6126803245594d97b2abbe2fa"
git checkout -b kubernetes-helm@2.9.0 7ade79f13b4bbcc6126803245594d97b2abbe2fa
HOMEBREW_NO_AUTO_UPDATE=1 brew install kubernetes-helm

Now we have needed version of helm.

If you see an error message like Error: go: unknown version :mountain_lion, you should make a little hack (as it said here). Check all the files depending on

grep 'depends_on :macos => :mountain_lion' Formula/*
# you'll see something like
Formula/bashdb.rb:  depends_on :macos => :mountain_lion
Formula/chrome-cli.rb:  depends_on :macos => :mountain_lion
Formula/clipsafe.rb:  depends_on :macos => :mountain_lion
Formula/go.rb:  depends_on :macos => :mountain_lion
Formula/go@1.8.rb:  depends_on :macos => :mountain_lion
Formula/go@1.9.rb:  depends_on :macos => :mountain_lion
Formula/ios-sim.rb:  depends_on :macos => :mountain_lion
Formula/mesos.rb:  depends_on :macos => :mountain_lion
Formula/mongodb.rb:  depends_on :macos => :mountain_lion
Formula/mongodb@3.0.rb:  depends_on :macos => :mountain_lion
Formula/mongodb@3.2.rb:  depends_on :macos => :mountain_lion
Formula/mongodb@3.4.rb:  depends_on :macos => :mountain_lion
...

In each file just comment a string saying depends_on :macos => :mountain_lion.
In my case commenting only in Formula/go.rb, Formula/go@1.8.rb, Formula/go@1.9.rb worked.

kubectl 1.13

If you need kubectl 1.13, you should do this:

git -C "$(brew --repo homebrew/core)" fetch --unshallow
cd "$(brew --repo homebrew/core)"
git log Formula/kubernetes-cli.rb
# searching for 2.9.0 with a command /1\.13\. and copying hash like "75af35f7bf344b6ac8436e3a60932504543d7012"
git checkout -b kubernetes-cli@1.13.4 75af35f7bf344b6ac8436e3a60932504543d7012
HOMEBREW_NO_AUTO_UPDATE=1 brew install kubernetes-cli
git checkout master
git branch -d kubernetes-cli@1.13.4

Links:
https://zoltanaltfatter.com/2017/09/07/Install-a-specific-version-of-formula-with-homebrew/

Another way

There is a completely different way to do this
https://blog.hogrebe.net/2019-04-kubernetes-helm-incompatible-clientserver-versions-max-os-x/

LEAVE A COMMENT