-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
build: vague error when TMPDIR is set to directory that doesn't exist #12823
Comments
Unless we check for this case explicitly, i don't think we can generate any PS: when debugging problems like this, go build -x will generally lead you The problem is that normally cmd/go tolerates a lot of missing directories And I don't think ioutil.TempDir should check for the case where $TMPDIR |
We provide os.TempDir and letting users to run arbitrary file operations on the returned value. On the other hand, the temp directory's status may change in the lifecycle of the Go program. It could be removed, created, mounted, unmounted, etc. From the Go context, without intercepting every file operation and checking whether the user is trying to access a TMPDIR directory or file, it is impossible to generate better error messages. Should we intercept each file op such as os.Open to provide better error messages if the specific file or directory is in the temp directory? It doesn't sound like the expected behavior to me given the fact users can log TMPDIR related error messages with more context in their programs. |
Yeah, I think we can't do anything here. Even if we fixed ioutil.TempDir to
check for the case, there could be other cases where the code tries to
use the temporary directory and fails. It doesn't make sense to check for
this special case everywhere in package os.
Closing as unfortunate.
|
Thank you for the detailed replies and for the tip on I understand that changing the behavior of My main concern is that a missing TMPDIR can cause
If providing a better error message after |
What version of Go are you using (go version)?
go version go1.5.1 linux/amd64
What operating system and processor architecture are you using?
Linux 2dddcbe0e2db 4.0.9-boot2docker #1 SMP Thu Sep 10 20:39:20 UTC 2015 x86_64 GNU/Linux
What did you do?
Ran
docker run --rm -it golang:1.5.1 /bin/bash -c "uname -a && go version && TMPDIR=/foo go build"
This is a simple example that represents setting TMPDIR to a directory that doesn't exist.
What did you expect to see?
An error telling me that TMPDIR is incorrectly set to a directory that doesn't exist.
What did you see instead?
a vague
no such file or directory
error (I'm usinggo build
here against no go files, but it fails the same way even if I point to a valid main.go file.)Since the error is so vague, I was initially scouring my go code for the misconfiguration, but the failure seems to happen before any go code is processed.
The text was updated successfully, but these errors were encountered: