Bug 2050088

Summary: [EPEL] 1.15 → 1.16 regression with GOROOT breaks cockpit build
Product: [Fedora] Fedora EPEL Reporter: Martin Pitt <mpitt>
Component: golangAssignee: Dave Dykstra <dwd>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: epel7CC: amurdaca, asm, deparker, dwd, jakob, jcajka, lemenkov, sipoyare, tschelle
Target Milestone: ---Keywords: Regression
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-09 13:02:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Pitt 2022-02-03 08:49:23 UTC
Description of problem: Recently, the Go compiler was updated in EPEL for RHEL 7 from 0:1.15.14-1.el7 to 0:1.16.13-2.el7.

This broke the building of the current RHEL 7 cockpit package [1]:

    GOPATH=/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone /usr/bin/go build -ldflags "-B 0x"`head -c20 /dev/urandom|od -An -tx1|tr -d ' \n'` "cockpit-kube-auth"

fails with

    package cockpit-kube-auth is not in GOROOT (/usr/lib/golang/src/cockpit-kube-auth)

I don't have any idea of Go (this is an old stable branch, the Go parts predate me and it has long been removed from RHEL 8/9 and main). But as far as I understand [2], one is *not* supposed to define $GOROOT when using distribution packages -- the builtin default (/usr/lib/golang/src) seems quite reasonable. I still understand the docs [2] that one should set GOPATH for building custom go packages, such as the one in cockpit's srpm.

Nevertheless, I experimented with this a bit, to no avail:


$ GOROOT=/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone GOPATH=/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone /usr/bin/go build -ldflags "-B 0x"`head -c20 /dev/urandom|od -An -tx1|tr -d ' \n'` "cockpit-kube-auth"
warning: GOPATH set to GOROOT (/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone) has no effect
pkg/kubernetes/standalone/src/cockpit-kube-auth/helpers/client.go:23:2: package bytes is not in GOROOT (/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone/src/bytes)
pkg/kubernetes/standalone/src/cockpit-kube-auth/helpers/client.go:24:2: package crypto/tls is not in GOROOT (/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone/src/crypto/tls)
[...]

→ Now it can't find its standard library packages any more, which is expected, I suppose? So let's try to add that:

$ GOROOT=/usr/lib/golang/src:/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone GOPATH=/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone /usr/bin/go build -ldflags "-B 0x"`head -c20 /dev/urandom|od -An -tx1|tr -d ' \n'` "cockpit-kube-auth"
go: cannot find GOROOT directory: /usr/lib/golang/src:/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone

→ Not using the standard ":" path separator either, or it doesn't support multiple paths in the first place (I suspect the latter).


I also dropped the "-ldflags" bits - I think that's just some kind of random build ID, but it doesn't influence this bug.

So at this point I don't know what to do -- at first sight this *looks* broken. Is there some workaround, or are we doing things wrong?


Version-Release number of selected component (if applicable):

golang-bin-0:1.16.13-2.el7

[1] https://logs.cockpit-project.org/logs/pull-2885-20220203-023426-fea26358-rhel-7-9-cockpit-project-cockpit-rhel-7.9/log.html
[2] https://golangdocs.com/gopath-and-goroot-in-go-programming

Comment 3 Martin Pitt 2022-02-03 09:05:32 UTC
I also tried to give it the full path to the package, instead of just the name:

  $ GOPATH=/builddir/build/BUILD/cockpit-195.12.x/pkg/kubernetes/standalone /usr/bin/go build pkg/kubernetes/standalone/src/cockpit-kube-auth/                  
  package pkg/kubernetes/standalone/src/cockpit-kube-auth is not in GOROOT (/usr/lib/golang/src/pkg/kubernetes/standalone/src/cockpit-kube-auth)

At this point it's behaving exactly like I didn't specify $GOROOT at all:

  $ /usr/bin/go build cockpit-kube-auth                               
  package cockpit-kube-auth is not in GOROOT (/usr/lib/golang/src/cockpit-kube-auth)

I just don't understand how GOROOT is related to finding packages? I though that was the location of the Go compiler and library?

Comment 4 Martin Pitt 2022-02-03 18:23:12 UTC
The 1.16 release notes[1] mention some GO111MODULE change. Setting this to "auto" effectively works around the problem indeed [2]. However, the error message is really .. unhelpful.

So feel free to close this as WONTFIX.

[1] https://go.dev/doc/go1.16
[2] https://github.com/cockpit-project/cockpit/pull/16921

Comment 5 Tilmann Scheller 2022-02-09 11:33:25 UTC
Moving to EPEL product

Comment 6 Dave Dykstra 2022-02-09 13:02:22 UTC
Thank you for reporting the problem and the fix.  

However, this is the upstream behavior, so we won't do anything in this distribution.  Closing as NOTABUG.