-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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: adjust PATH
when go run
/go generate
runs the built binary
#68005
Labels
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Comments
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
seankhliao
added
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
GoCommand
cmd/go
labels
Jun 15, 2024
From a brief investigation looks like 'go generate' already adjusts the path accordingly since CL 404134. I'll push a fix for |
Change https://go.dev/cl/593255 mentions this issue: |
This seems reasonable to me. Thanks for the CL! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Go version
go version go1.22.0 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
Since my local version is go1.21.9, but my go.mod requires go1.22.0+,
toolchain switch occurs when running
go run .
. During the toolchain switchthe go command sets
GOROOT
so the switched go command can choosethe toolchains correctly.
When
go run
executes the compiled binary, thisGOROOT
is left behind.But the PATH is unchanged.
This can be potentially problematic, if the binary invokes
go install mod@ver
, or runsgo build
outside the current module.In my specific case, /usr/local/go/bin/go is go1.21.9, but
GOROOT
is go1.22.0 root.The
go install
orgo generate
program will fail to run due to this mismatched binary/GOROOT pair.@rsc said 'go test' handles this problem by adjusting
PATH
, too.We should do the same for
go run
,go generate
, ...What did you expect to see?
Subprocess can pick matching
go
binary andGOROOT
.The text was updated successfully, but these errors were encountered: