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: can only run "go env" in certain places #35409

Closed
bradfitz opened this issue Nov 7, 2019 · 1 comment
Closed

cmd/go: can only run "go env" in certain places #35409

bradfitz opened this issue Nov 7, 2019 · 1 comment

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Nov 7, 2019

I've historically checked out my Go development trees to $HOME/go. (where it naturally falls if you do git clone https://go.googlesource.com/go without an additional argument)

That habit predates the new automatic GOPATH value of $HOME/go.

But that led to this surprising behavior on a new machine I was benchmarking:

In $HOME/go ...

[ec2-user@ip-172-31-7-89 go]$ pwd
/home/ec2-user/go
[ec2-user@ip-172-31-7-89 go]$ git remote -v
origin	https://go.googlesource.com/go (fetch)
origin	https://go.googlesource.com/go (push)

Here's $HOME/go/bin/go's version command showing that I just built Go...

[ec2-user@ip-172-31-7-89 go]$ ./bin/go version
go version devel +198f0452b0 Thu Nov 7 02:33:31 2019 +0000 linux/arm64

And can run go env from $HOME/go too....

[ec2-user@ip-172-31-7-89 go]$ ./bin/go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOENV="/home/ec2-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH=""
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ec2-user/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ec2-user/go/pkg/tool/linux_arm64"
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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build676408819=/tmp/go-build -gno-record-gcc-switches"

But if I cd down into src (which contains a go.mod file), I can't use the same go binary anymore to run go env (or run go tool dist test, etc):

[ec2-user@ip-172-31-7-89 go]$ cd src/
[ec2-user@ip-172-31-7-89 src]$ ../bin/go env
missing $GOPATH
[ec2-user@ip-172-31-7-89 src]$ ../bin/go tool dist test
2019/11/07 04:26:01 Error running go env CGO_ENABLED: exit status 1

Is this working as intended?

Can it be made more helpful if I'm holding it wrong?

/cc @bcmills

@bradfitz bradfitz changed the title cmd/go: can run "go env" in certain places cmd/go: can only run "go env" in certain places Nov 7, 2019
@bcmills
Copy link
Contributor

bcmills commented Nov 7, 2019

Duplicate of #34628

@bcmills bcmills marked this as a duplicate of #34628 Nov 7, 2019
@bcmills bcmills closed this as completed Nov 7, 2019
@golang golang locked and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants