38

Specifically kubernetes-cli. I have 1.12.0 installed. I need 1.11.x, but I don't have that installed.

I've reviewed and tried every answer in this thread and nothing worked: Homebrew install specific version of formula?

I've tried brew search but there are no tapped versions:

~ brew search kubernetes-cli
==> Formulae
kubernetes-cli ✔

I've tried brew versions but that command has been removed:

~ brew versions 
Error: Unknown command: versions

I've tried brew install kubernetes-cli@1.11.0 and .1 and .2:

~ brew install kubernetes-cli@1.11.0
Error: No available formula with the name "kubernetes-cli@1.11.0" 
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

brew switch requires that I have the older version installed, which I don't.

~ brew switch kubernetes-cli 1.11.0
Error: kubernetes-cli does not have a version "1.11.0" in the Cellar.
kubernetes-cli installed versions: 1.12.0
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
clay
  • 18,138
  • 28
  • 107
  • 192
  • Exactly not answer to this question, but if anybody wants to install a specific version of kubernetes-cli, following steps in https://kubernetes.io/docs/tasks/tools/install-kubectl/ is much easier than any of the answers mentioned below. – ashish malgawa Mar 20 '20 at 10:00
  • brew doesn't generally support old package installation any more so you may be better off using something like https://macports.org, https://github.com/LnL7/nix-darwin, or https://pkgsrc.joyent.com – Pierz May 24 '22 at 12:40

7 Answers7

32
  1. Go to homebrew git repo: https://github.com/Homebrew/homebrew-core/
  2. Identify the commit specific to kubernetes 1.11.x version
  3. Go to Formula folder
  4. Open raw version of kubernetes-cli.rb file
  5. Copy the raw link of the file https://raw.githubusercontent.com/Homebrew/homebrew-core/3e8f5503dde7069c5ff49b82d5e1576e6ebe3a5d/Formula/kubernetes-cli.rb
  6. Run brew install <raw_link>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
urpalreloaded
  • 468
  • 3
  • 13
  • 2
    I used `brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/41764e07727d9a86b0f8a077117dc7876ca294c4/Formula/kubernetes-cli.rb` and these instructions to install v.1.11.3. – GrandAdmiral Dec 11 '18 at 19:23
  • 1
    I used the combination of this and the answer from @Erik K below to install an earlier version of kubernetes-helm. Erik's answer should be incorporated into this one in place of the "Identify the commit" step. – Chuck Wilbur Feb 13 '19 at 21:08
  • _rdump_ has made a real effort to collect helm commit links for previous kubectl versions: [https://gist.github.com/rdump/b79a63084b47f99a41514432132bd408#example-install-commands](https://gist.github.com/rdump/b79a63084b47f99a41514432132bd408#example-install-commands) – jorgenkg Aug 02 '20 at 19:33
  • How to get raw file from a specific commit? – electrodrel Aug 05 '21 at 19:32
  • 9
    Apparently, the recent homebrew version removed the support to install via a raw link. `Invalid usage: Installation of activemq from a GitHub commit URL is unsupported!` – Harish Nov 02 '21 at 14:50
  • 5
    I installed with `brew install kubernetes-cli@1.22`. I was getting: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/75b367efca10dece21b2d68c55f45f6f0320d56f/Formula/kubernetes-cli.rb Running `brew update --preinstall`... Error: Installation of kubernetes-cli from a GitHub commit URL is unsupported! `brew extract kubernetes-cli` to a stable tap on GitHub instead. – Miguel Reyes Mar 22 '22 at 23:08
  • 1
    You can look at this guide: https://cmichel.io/how-to-install-an-old-package-version-with-brew/ – bertonc96 Sep 28 '22 at 14:00
25

I dont have enough rep to make a comment on the answer that helped me. So writing here to be more specific about point 2 from @urpalreloaded

  1. brew search --pull-request kubernetes-cli@1.11.0
  2. It will say that it did not find the cask but should give you a link to a closed pull request that matches the version you searched for. Follow the link to the pull request and the follow steps 3-5.
  3. brew unlink kubernetes-cli
  4. brew install <raw-link>

FWIW, I think brew doesnt keep versions because it will make the repo too big? This workaround is inconvenient and perhaps they could find a way around this issue on their end?

Erik K
  • 471
  • 5
  • 12
3

The above answers were really useful but when I tried to install Carthage 0.30.1 on my Sierra 10.12.6 machine I got a SHA256 mismatch error:

$ brew install https://raw.githubusercontent.com/ilovezfs/homebrew-core/8c93668a451087611b2247cafe02ad6f867daed6/Formula/carthage.rb --force-bottle
######################################################################## 100.0%
Warning: carthage 0.32.0 is available and more recent than version 0.30.1.
==> Downloading https://homebrew.bintray.com/bottles/carthage-0.30.1.sierra.bottle.tar.gz
######################################################################## 100.0%
Error: SHA256 mismatch

and then it failed to build from source due to latest Sierra Xcode not supporting the new Xcode build system.

What worked for me was to directly install from the bottle (the url is shown in first brew install <raw url> output):

brew install https://homebrew.bintray.com/bottles/carthage-0.30.1.sierra.bottle.tar.gz
dsjapan
  • 46
  • 4
1

I have the same problem as dsjapan and what worked for me was changing to high sierra:

brew unlink carthage
brew install https://homebrew.bintray.com/bottles/carthage-0.30.1.high_sierra.bottle.tar.gz
0

As of Apr 2022:

The easiest way I found was to create a new tap.

The Guru
  • 55
  • 6
0

For kubernetes-cli specifically (and if you don't care about patch versions - the x in 1.11.x), you can just use:

brew install kubernetes-cli@1.11

And it will complete with the latest x available.

wscourge
  • 10,657
  • 14
  • 59
  • 80
0

I figured out how to both upgrade and downgrade any formula that's been disabled due to deprecation.
(basically I followed this guide and set an additional brew environment variable)

In my case I did the following to upgrade from 1.22.16 to 1.22.17 (latest before deprecation):

  1. Run:
brew edit kubernetes-cli@1.22
  1. Comment this line that begins with disable! date:
# disable! date: "2022-10-28", because: :deprecated_upstream
  1. Run:
HOMEBREW_NO_INSTALL_FROM_API=1 brew upgrade kubernetes-cli@1.22

To roll back or generally install any other version, continue with these steps instead:

  1. Replace all lines with all the lines from the version that you want, which can easily be found via the commit history (once in commit click ... -> View file) or:
brew log kubernetes-cli@1.22
  1. Run:
HOMEBREW_NO_INSTALL_FROM_API=1 brew reinstall kubernetes-cli@1.22
EliadL
  • 6,230
  • 2
  • 26
  • 43