2

I am trying to install go 1.8.

The apt package of anything but golang-1.7 doesn't work. Golang-1.7 installs properly, golang-1.8 doesn't. Is the package in the repo wrong/incomplete?

Debian claims for golang-1.8 "This package is a metapackage that, when installed, guarantees that (most of) a full Go development environment is installed." https://packages.debian.org/stretch/golang-1.8 But that's obviously not true.

# apt install golang-1.8 golang-1.8-go
Reading package lists... Done
Building dependency tree
Reading state information... Done
golang-1.8 is already the newest version (1.8.1-1).
golang-1.8-go is already the newest version (1.8.1-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
# go
bash: /usr/bin/go: No such file or directory
# whereis go
go:
# uname -a
Linux linux 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
# cat /etc/debian_version 
9.4
0

1 Answer 1

3

Background

«guarantees … is installed» merely means it depends on a set of packages which actually provide Go dev. env.

As you can see, this package depends on three other packages—golang-1.8-doc, golang-1.8-go, golang-1.8-src—so when you install golang-1.8, those three will be installed as well.

The problem you're experiencing is, I must admit, indeed confusing but can be easily explained.

If you'll look at the list of packages installed by golang-1.8-go, you'll see that the go tool is installed as /usr/lib/go-1.8/bin/go, and the directory /usr/lib/go-1.8/bin is not listed in the default PATH environment variable (set by /etc/profile).

The reason it's done this way is twofold:

  • There can be several groups of golang-X.Y* packages in the same Debian suite at the same time; say, Stretch has 1.7 and 1.8.

    It's crucial to understand that they are co-installable, which may be useful to test how a project which was tested against X.Y will work with X.Y+N.

  • Debian provides a special "the most generic" Go package which depends on a specific golang-X.Y package which was deemed to be "the standard" for the parcicular Debian release.

    In Stretch, it's golang-go, and as you can see, it has "1.7" in its version and depends on golang-1.7-go.

    This package makes sure the executable binaries provided by a specific default golang-X.Y-go package are available in "the standard place" — under /usr/bin (see for yourself).

What to do about it?

Several possiblilties:

  • Merely call /usr/lib/go-1.8/bin/go by its full pathname.

    The go tool "knows" where its GOROOT is so it will find its packages specific to its version just fine.

  • Prepend that directory to your path variable; say put something like

     export PATH="/usr/lib/go-1.8/bin:$PATH"
    

    into your ~/.bashrc script and the next call to go will find it in the new place.

  • Grab the source of the golang-go package, fix it so that it makes golang-1.8-go the default package, build it and install.

    (I'd not recommend to go this way just yet.)

Hope this helps.


Another stab at explaining

Stretch has two packs of three packages: golang-1.7-* and golang-1.8-*.

In each, pack, the golang-1.N-go package installs its go binary under /usr/lib/go-1.N/bin. Neither of them installs a symlink under /usr/bin.

The reason for this is to make these packs of packages co-installable, so that you can compile your Go code with any of the installed versions.

Now there is another, independent, package, which does not encode Go release version in its name. It's named golang-go, and it depends only on golang-1.7-go where 1.7 is the default version of Go runtime for Stretch.

In another release, golang-go will depend on another golang-X.Y-go package.

It is this package, which provides /usr/bin/go pointing at /usr/lib/go-1.7/bin/go.

So if (and only if) you have golang-go installed, will you have the go binary available under /usr/bin, and that will be of Go 1.7 in Stretch.

And no, it's not possible to somehow force golang-go to point at go from the installed golang-1.8-go package, and neither is there a way to select a preferred Go version via the "dpkg alternatives" mechanism.

My take on "the why" of this approach is to have a well-known version of go in any given Debian release. This is supposedly needed for building Debian packages of software written in Go. Otherwise, it would be required for package building machinery to invent some trickery for finding the default version of Go; as of now, their source packages may just depend on golang-go and call it a day.

2
  • Thanks for your reply. I know now how to access the program but I still am confused about why this happens, I never had this. Yes golang-1.8 installs all the deps you mentioned but shouldn't then be at least a symlink created with /usr/bin/go -> /usr/lib/go-1.8/bin/go? Commented Apr 26, 2018 at 14:34
  • 1
    I've explained this. Supposedly I failed to convery that properly. Let's have another stab. Updated my answer.
    – kostix
    Commented Apr 26, 2018 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .