-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: panic when building a main
package in GOPATH mode when a go.work file exists
#58767
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
Comments
The stack trace in the failure shows
That suggests that |
Additional information: I modified the test to print out working directories and environments, then started pruning the environment, and eventually discovered that the failure was sensitive to the directory. If I ran the command in
Contents of $GOPATH in that command:
So, that is the workaround, presence of go.work is suspected to be the trigger. At minimum, the test ought to detect this and fail in a more informative way. |
Turns out I typed "go env" in a different directory than the one where it was crashing, which explains the missing |
Change https://go.dev/cl/471600 mentions this issue: |
Change https://go.dev/cl/471601 mentions this issue: |
main
package in GOPATH mode when a go.work file exists
Workspace mode is specifically for working with modules; it doesn't make sense in GOPATH mode. This also fixes a panic in (*modload.MainModuleSet).GoVersion when go.work is present in GOPATH mode. For #58767. Change-Id: Ic6924352afb486fecc18e009e6b517f078e81094 Reviewed-on: https://go-review.googlesource.com/c/go/+/471600 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Some folks working on the Go project may have a go.work file in GOROOT/src in order to test changes in x repos. 'go test cmd/go' should not fail if that is the case. For #58767. Change-Id: I0e57b15fb1d3e4abc4903c177434626c9f125cae Reviewed-on: https://go-review.googlesource.com/c/go/+/471601 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com>
I believe this is now fixed, but please let me know if you're still seeing failures. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
success
What did you see instead?
many failures, all sharing (some fraction of) the stack trace
I tried to debug this by reproducing the actions for
TestFFLAGS
but could not figure out the right way to run the command, so was unable. I wanted this failure:but because I could not figure out the exact environment for running go (the test claimed to be running "testgo"), instead I saw
When I guessed at a way to run the command (
cd ~/work/src/fflags/p/src/p; go build main.go
-- no idea if this is what the test harness was doing or not) I got the successful expected failurebut I have no idea what's actually going on here, I am just guessing. Darn shame the test was not more explicit about the details of what it was trying to do.
The text was updated successfully, but these errors were encountered: