-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: go tool -n
can point to a file that doesn't exist
#72824
Comments
seems like when it builds a tool it prints the location of it in the temporary work directory, rather than the final location in the build cache |
I figured out the cause on the bug. would u mind if i take this issue up and propose a PR |
Change https://go.dev/cl/658395 mentions this issue: |
The behavior in your repro log doesn't match what I'd expect: specifically my expectation is that we return the temp file location the first time we run go tool (where the tool is not yet cached) and the location to the cached path afterwards. Here's a log from my repro:
What's happening is that the first time we build the binary, we build the executable to a temporary directory and then execute the command from the built location. (This is what go run did before executable caching was added) Every subsequent time, we fetch the executable from the cache and run it from there. If we decide to, we can make the example work by setting the 'built' field to be the cache location of the executable in the last condition in I'm a bit unsure of doing this because the cache is supposed to be an implementation detail of the go command and it might not be a good idea for tools to depend on the path of the file in the cache. It is better to run Of course if we decide that the file returned by |
@matloob I wanted to propose the same change considering a different implementation (behind the Also in my opinion, with the |
Go version
go version go1.24.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I was using
go tool -n github.com/iwahbe/helpmakego
in my Makefile to work around #71733 like this:I noticed that sometimes
$(shell ${HELPMAKEGO} ...)
would fail unexpectedly, saying that there was no file at${HELPMAKEGO}
.I can replicate this behavior locally:
You will see that every other time
go tool -n github.com/iwahbe/helpmakego
it points to a file that doesn't exist.What did you see happen?
What did you expect to see?
I expect that any time
go tool -n ...
is run, it will point to a runnable executable.If that isn't true, then
go help tool
should document what conditions are necessary to ensure thatgo tool -n ...
will point to an executable file.The text was updated successfully, but these errors were encountered: