-
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
: missing diagnostic when the default GOPATH
conflicts with an explicit GOROOT
#60492
Comments
go/cmd
: go run
launched by go generate
fails to locate module cachecmd/go
: go run
launched by go generate
fails to locate module cache
how did you end up with GOROOT == GOPATH? |
By unpacking the tarball into
The config file doesn't exist. I can confirm that the issue goes away when GOROOT != GOPATH. |
That's perhaps the only place where it doesn't work. I don't think we recommend doing what you did anywhere? |
I don’t think “first party” resources suggest doing what I did. There might have been some third party ones, at least some years back when I did the setup. It would be nice if the toolchain plain rejected this invalid setup rather than breaking in subtle ways. Otherwise, please feel free to close. Thank you very much for the help! |
It is supposed to: However, that warning has no effect if It looks like the attempt to improve the error message in https://go.dev/cl/331529 was incomplete. It should probably be extended to more places. |
cmd/go
: go run
launched by go generate
fails to locate module cachecmd/go
: missing diagnostic when the default GOPATH
conflicts with an explicit GOROOT
Change https://go.dev/cl/538738 mentions this issue: |
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?
It used to be possible to have
go run
inside//go:generate
lines. It is very handy since a project can require the specific generator version viago.mod
.Following examples by
cilium/ebpf
, I created amain.go
file...and invoked
go generate ./...
.(I'm using a specific generator in my bug report, but it looks like a generic issue affecting anyone using
go run
insidego:generate
technique. Therefore I believe that the specific generator being used is irrelevant.)What did you expect to see?
The generator to complain about missing arguments.
What did you see instead?
Further info
If I invoke
go run
directly, everything works as expected.It's clear that the generator gets executed and complains as expected.
However, if I set
GOROOT
(asgo generate
does):Changing
go:generate
line as below also "fixes" the problem:I believe that I have the most boring go setup possible.
$ env | grep GO
yields nothing.The text was updated successfully, but these errors were encountered: