Does this issue reproduce with the latest release?
I haven't confirmed with go1.17beta1, but a quick scan through the history of cmd/go doesn't show any relevant changes, and I don't see any relevant issues on goissues.org.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\zephyr\AppData\Local\go-build
set GOENV=C:\Users\zephyr\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=E:\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\zephyr\AppData\Local\Temp
\go-build4050350410=/tmp/go-build -gno-record-gcc-switches
What did you do?
Create $GOPATH/go.mod, then execute the go tool:
PS C:\Users\zephyr\bug>$Env:GOENV="C:\Users\zephyr\bug\env"
PS C:\Users\zephyr\bug> go env -w GOPATH="C:\Users\zephyr\bug"
PS C:\Users\zephyr\bug> go mod init bug
go: creating new go.mod: module bug
go: to add module requirements and sums:
go mod tidy
PS C:\Users\zephyr\bug> go env GOPATH
$GOPATH/go.mod exists but should not
PS C:\Users\zephyr\bug> go env
$GOPATH/go.mod exists but should not
A user encountered this issue after possibly VSCode or some other program set GOPATH in $GOENV. echo $GOPATH was empty, and ~/go/go.mod did not exist. They weren't able to inspect the go tool's value of GOPATH to diagnose the error because every go tool invocation (including go env -u GOPATH) gave only $GOPATH/go.mod exists but should not, and nothing suggested checking $GOENV or its default value.
What did you expect to see?
go env should print the environment regardless of whether $GOPATH/go.mod exists. It probably also should allow setting and unsetting variables.
Alternatively, the error message should print the value of GOPATH instead of only the variable name.
Another option would be to indicate that the user should check $GOENV if they think GOPATH should not contain go.mod.
What did you see instead?
$GOPATH/go.mod exists but should not
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I haven't confirmed with go1.17beta1, but a quick scan through the history of cmd/go doesn't show any relevant changes, and I don't see any relevant issues on goissues.org.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Create
$GOPATH/go.mod
, then execute the go tool:A user encountered this issue after possibly VSCode or some other program set GOPATH in $GOENV.
echo $GOPATH
was empty, and ~/go/go.mod did not exist. They weren't able to inspect the go tool's value of GOPATH to diagnose the error because every go tool invocation (includinggo env -u GOPATH
) gave only$GOPATH/go.mod exists but should not
, and nothing suggested checking $GOENV or its default value.What did you expect to see?
go env
should print the environment regardless of whether$GOPATH/go.mod
exists. It probably also should allow setting and unsetting variables.Alternatively, the error message should print the value of GOPATH instead of only the variable name.
Another option would be to indicate that the user should check $GOENV if they think GOPATH should not contain go.mod.
What did you see instead?
$GOPATH/go.mod exists but should not
The text was updated successfully, but these errors were encountered: