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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: installs cmd/... in $GOBIN now #32674

Closed
mvdan opened this issue Jun 18, 2019 · 4 comments
Closed

cmd/go: installs cmd/... in $GOBIN now #32674

mvdan opened this issue Jun 18, 2019 · 4 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Jun 18, 2019

I've been setting GOBIN manually for a while now. I also run go install cmd/go somewhat regularly, to test changes I make to the tool.

Recently, I started noticing a $GOBIN/go binary, which makes no sense to me. I always thought that go install cmd would populate $GOROOT/bin, not $GOBIN. The recent changes in 530097f seem to agree with me:

Note that the Go distribution's executables are installed in $GOROOT/bin (for executables invoked by people) or $GOTOOLDIR (for executables invoked by the go command;
defaults to $GOROOT/pkg/$GOOS_GOARCH) instead of $GOBIN.

Below is how I reproduced this on my system, which is running a somewhat recent master version. I verified that this regression doesn't show in 1.12.6 by building that tag from source and testing again.

$ go version
go version devel +7a4d02387f Sun Jun 16 20:04:54 2019 +0000 linux/amd64
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/mvdan/go/bin"
GOCACHE="/home/mvdan/go/cache"
GOENV="/home/mvdan/.config/go/env"
GOEXE=""
GOFLAGS="-ldflags=-w"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="brank.as/*"
GONOSUMDB="brank.as/*"
GOOS="linux"
GOPATH="/home/mvdan/go"
GOPRIVATE="brank.as/*"
GOPROXY="https://proxy.golang.org"
GOROOT="/home/mvdan/tip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/mvdan/tip/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build811082871=/tmp/go-build -gno-record-gcc-switches"
$ echo $GOBIN
/home/mvdan/go/bin
$ which go
/home/mvdan/tip/bin/go
$ ls ~/go/bin/go
ls: cannot access '/home/mvdan/go/bin/go': No such file or directory
$ go install cmd/go
$ ls ~/go/bin/go
/home/mvdan/go/bin/go*

I don't have the time to bisect now, but I can do that later this week if that's necessary. One perhaps important piece of information is that this problem disappears if I stop exporting $GOBIN; perhaps the bug is that go install isn't properly ignoring an explicitly set $GOBIN when installing cmd.

The fact that make.bash unsets the variable seems to back up this theory. However, that's #14340, which seems related but not the same issue.

/cc @bcmills @jayconrod

@mvdan mvdan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 18, 2019
@dmitshur dmitshur added this to the Go1.13 milestone Jun 18, 2019
@jayconrod jayconrod self-assigned this Jun 19, 2019
@jayconrod jayconrod 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 19, 2019
@gopherbot
Copy link

Change https://golang.org/cl/183058 mentions this issue: cmd/go: install binaries in cmd/ in $GOROOT/bin instead of $GOBIN

@gopherbot
Copy link

Change https://golang.org/cl/215478 mentions this issue: build: in clean.bash, look for 'go' in GOROOT/bin instead of GOBIN

gopherbot pushed a commit that referenced this issue Feb 26, 2020
Updates #14340
Updates #32674
Fixes #36659

Change-Id: I5bfaba4e53dab894d113dd5065794d66f1a25f2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/215478
Reviewed-by: Bryan C. Mills <bcmills@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/223744 mentions this issue: run.{bash,bat}: prefer 'go env' from ../bin/go instead of whatever is in $PATH

@gopherbot
Copy link

Change https://golang.org/cl/223741 mentions this issue: run.{bash,bat}: prefer 'go env' from ../bin/go instead of whatever is in $PATH

gopherbot pushed a commit that referenced this issue Mar 27, 2020
https://golang.org/doc/contribute.html#quick_test currently suggests
running 'make.bash' and 'run.bash' separately, but 'run.bash'
potentially uses a 'go' command resolved from the wrong GOROOT,
which in turn sets the wrong GOROOT for further commands.

Updates #32674
Updates #17896

Change-Id: I4925d478d0fc7351c4f6d40830ab17d4d688348d
Reviewed-on: https://go-review.googlesource.com/c/go/+/223741
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
@golang golang locked and limited conversation to collaborators Mar 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants