Run go test on a system with /tmp mounted as noexec.
What did you expect to see?
Tests run, or some helpful suggestion on how to fix the problem.
What did you see instead?
fork/exec /tmp/go-build/...: .permission denied
In #8451 the new GOTMPDIR was added, allowing a user to configure their system to fix this situation. Unfortunately the Go command does not provide that context or recommendation to me as a user if it runs into this situation.
On systems using systemd a reasonable choice could be to instead default to XDG_RUNTIME_DIR (with fallbacks to (GO)TMPDIR), which has the added benefit of being tied to the user session (instead of being a system-wide thing) and getting cleaned up somewhat regularly. Checking if that environment variable is defined ought to be enough, as it's set by pam-systemd (or was explicitly set by the user).
Regardless of potential changes to the default behaviour, I think it would be helpful to users if the go command could output the suggestion to configure GOTPMDIR in case it hits the permission denied case when launching the test binary.
The text was updated successfully, but these errors were encountered:
$ gotip run main.go
go: creating work dir: mkdir /tmp/go-build1759159385: permission denied.
Run 'go env -w GOTMPDIR=...' to specify another temporary directory.
For more about GOTMPDIR, see 'go help environment'.