Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to brew switch go versions

Tags:

homebrew

go

I have go versions 1.13.1 and 1.12.9 installed

$brew list --versions | grep go
go 1.13.1
[email protected] 1.12.9

But I am unable to switch to 1.12, an error indicates that I only have version 1.13.1 installed contradicting the earlier listing.

$brew switch go 1.12
Error: go does not have a version "1.12" in the Cellar.
go installed versions: 1.13.1

And when I look carefully at go versions (no grep)

$brew list --versions go
go 1.13.1

So I must have done something wrong when I installed go 1.12, but what? I used brew install [email protected], should I have used another syntax?

like image 801
mipnw Avatar asked Oct 03 '19 00:10

mipnw


People also ask

How do I get multiple versions of go?

How to Work With Multiple Go Versions. We can use the go install command to download install individual versions of Go. Running go install golang.org/dl/go<version>@latest will download and install a wrapper Go command for the specific Go version.

How do I change my brew version?

Installing an older version you never had installed before Since Homebrew doesn't provide a command to arbitrarily select a version to install, you have to manually find the version you need in Homebrew's GitHub repository, copy the URL to it and pass it as an argument for manual installation.


1 Answers

go and [email protected] are installed as two packages with different names, which means they are installed at different locations. /usr/local/Cellar/go and /usr/local/Cellar/[email protected].

In this situation, you should use brew link.

brew unlink go

brew link [email protected] --overwrite

Update 1

More explanation about brew switch. brew switch <version> is used to switch version installed with the same package name.

For example, If both go 1.13 and 1.13.1 installed, they're put in

  • /usr/local/Cellar/go/1.13
  • /usr/local/Cellar/go/1.13.1

In this situation, use brew switch.

brew switch go 1.13
brew switch go 1.13.1

Update 2

brew switch has been dropped since Homebrew 2.6.0.

Anyone still want the old brew switch, use the following tap, where brew switch is included as a custom sub-command.

brew tap laggardkernel/tap
brew switch --help
like image 139
Simba Avatar answered Oct 26 '22 08:10

Simba