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: Setting an invalid path with "go env -w GOTMPDIR=x" prevents use of go tool #40932

Closed
noxer opened this issue Aug 20, 2020 · 5 comments
Closed
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@noxer
Copy link

noxer commented Aug 20, 2020

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

PS C:\Users\noxer> go.exe version
go version go1.15 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
PS C:\Users\noxer\> go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\noxer\AppData\Local\go-build
set GOENV=C:\Users\noxer\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\noxer\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\noxer\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 GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\noxer\AppData\Local\Temp\go-build955719846=/tmp/go-build -gno-record-gcc-switches

What did you do?

I experimented with go env -w and set GOTMPDIR to an invalid path. No check prevented me from doing it. After the change the Go tool would not run any more, preventing me from resetting or correcting the path.

PS C:\Users\noxer> go env -w GOTMPDIR=x
PS C:\Users\noxer> go env -w GOTMPDIR= 
go: creating work dir: CreateFile x: The system cannot find the file specified.

This completely prevents use of the go tool until the user locates the env file in AppData\go and removes or edits it.

What did you expect to see?

I expected at least the go env (-w) commands to be available to correct the mistake.

What did you see instead?

The go tool terminates with the message go: creating work dir: CreateFile x: The system cannot find the file specified..

@noxer noxer changed the title Setting an invalid path with "go env -w GOTMPDIR=x" prevents use of go tool cmd/go: Setting an invalid path with "go env -w GOTMPDIR=x" prevents use of go tool Aug 20, 2020
@ianlancetaylor
Copy link
Contributor

CC @jayconrod @bcmills

@jayconrod jayconrod added this to the Go1.16 milestone Aug 20, 2020
@jayconrod jayconrod added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 20, 2020
@jayconrod
Copy link
Contributor

jayconrod commented Aug 20, 2020

go env -w won't check that the path exists, since you might intend to create it in a later step. Perhaps it should at least check whether it's an absolute path though.

go env -u GOTMPDIR may be used to unset the variable. Perhaps go env -w GOTMPDIR= should do the same thing.

In any case, neither go env -w nor go env -u should require a valid GOTMPDIR.

@gopherbot
Copy link

Change https://golang.org/cl/250198 mentions this issue: cmd/go: env -w validates GOTMPDIR value

@deven96
Copy link

deven96 commented Aug 26, 2020

So the fix is to make sure the path is absolute?. Can I work on this @jayconrod

@jayconrod
Copy link
Contributor

@deven96 Looks like there's already a fix for this pending review, linked above.

@golang golang locked and limited conversation to collaborators Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

5 participants