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 · 1 comment
Closed

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

mvdan opened this issue Jun 18, 2019 · 1 comment
Assignees
Milestone

Comments

@mvdan
Copy link
Member

@mvdan 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

@dmitshur dmitshur added this to the Go1.13 milestone Jun 18, 2019
@jayconrod jayconrod self-assigned this Jun 19, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jun 19, 2019

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

@gopherbot gopherbot closed this in 71a6a44 Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.