Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "go bug" in build on different branch reports version different than "go version" #43981

Closed
zikaeroh opened this issue Jan 29, 2021 · 5 comments
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@zikaeroh
Copy link
Contributor

What version of Go are you using (go version)?

(Note that the below is wrong; see the rest of the bug details. 馃檪)

$ go version
go version go1.15.7 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOENV="/home/jake/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jake/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jake/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jake/zikaeroh/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jake/zikaeroh/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build237692121=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version devel +aca22bddf2 Wed Jan 27 21:57:05 2021 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel +aca22bddf2 Wed Jan 27 21:57:05 2021 +0000
uname -sr: Linux 5.10.10-zen1-1-zen
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.32.
gdb --version: GNU gdb (GDB) 10.1

What did you do?

I checked out dev.regabi, then did a ./make.bash. Then I ran go bug from my checkout's bin like ~/zikaeroh/go/bin/go bug.

What did you expect to see?

Open a browser with the commit from the branch, and the version filled in matches go version.

What did you see instead?

The version is of the wrong build (see the version at the top of this issue; which was generated with go bug). Running go version the same way as go bug reports:

go version devel +aca22bddf2 Wed Jan 27 21:57:05 2021 +0000 linux/amd64

Looking at the source for go bug, it seems to just run go version from $PATH, instead of reexecing itself or ensuring $GOROOT/bin is in $PATH (as does go env, apparently). I can see that GOROOT/bin/go version is printed as an environment variable, but it surprises me for the main version listed in the bug template to be of a different Go. (Maybe I'm the only one running a go binary directly and relying on implicit $GOROOT?)

@seankhliao seankhliao added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 29, 2021
@bcmills bcmills added this to the Backlog milestone Jan 29, 2021
@gopherbot
Copy link

Change https://golang.org/cl/288693 mentions this issue: cmd/go: use implicit GOROOT for version and env

@gopherbot
Copy link

Change https://golang.org/cl/312390 mentions this issue: cmd/go/internal/bug: always use go from GOROOT/bin

@perillo
Copy link
Contributor

perillo commented Apr 22, 2021

I sent a different CL in order to fix this issue.
Note that I removed the entry for GOROOT/bin/go version, since it is no more necessary now that go bug always uses the go command from GOROOT/bin.

Thanks.

@perillo
Copy link
Contributor

perillo commented Apr 23, 2021

@seankhliao, sorry; I sent two issues about the same bug.

@perillo
Copy link
Contributor

perillo commented Apr 23, 2021

As far as I know, after c3e2ed7 go bug now prints the same go version twice, one from runtime.Version and the other from GOROOT/bin/go version.

@dmitshur dmitshur modified the milestones: Backlog, Go1.17 Jun 27, 2021
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 27, 2021
@golang golang locked and limited conversation to collaborators Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants