Skip to content

cmd/go: Setting an invalid path with "go env -w GOTMPDIR=x" prevents use of go tool #40932

@noxer

Description

@noxer

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..

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions