-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 build errors that don't correspond to source file until build cache is cleared #69179
Comments
I think somethhing to do with the module index? Cache verify:
With the module index on (default):
With module index off, build succeeds:
|
I'll look into this |
Let me know if there's anything I can do to help debug further! |
@matloob @seankhliao Quick question pending the investigation on your end, is there any obvious reason it would be a bad idea to run with Asking because this bug is causing lots of problems in our CI test suite specifically, so I'm considering just disabling the mod index there while things get figured out upstream here. In some preliminary runs I didn't notice any performance impact for us when running with it disabled for the whole test suite (and no occurrences of the bug so far 🤞). However, that |
I don't think disabling the module index should cause any correctness problems. (edit: correctness, not performance) |
Go version
go version go1.23.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
When attempting to build a valid go program, we are getting errors about imports on certain lines of source code that don't match the actual contents of the source file they are reported on. The errors go away and the program builds successfully once the go build cache at
/root/.cache/go-build
is deleted and nothing else changes.The repro is quite complex and takes a long time to trigger, so the best I could do for now was create a docker image with the go toolchain, source code and go build cache in place that reproduces the problem. Including commands for reproducing with that image below.
For more context, we are hitting this in Dagger, which is a container-based DAG execution engine that, among other things, does a lot of containerized building of Go code.
We specifically see this problem arise during integration tests, which will run, over the course of ~20min, many (probably 100+)
go build
executions in separate containers. The most relevant details I can think of:/root/.cache/go-build
) and the go mod cache (always mounted at/go/pkg/mod
)/src
and built with the commandgo build -o /runtime .
from within that/src
directory/src/internal
. They may also have the same go mod name at times.go build
,go mod tidy
, etc. in containersWhat did you see happen?
As mentioned above, the best I could do for now was capture the state of one of the containers hitting this error in a docker image. I pushed the image to dockerhub at
eriksipsma/corrupt-cache:latest
. It's alinux/amd64
only image unfortunately since that's what our CI is, which is the only place I can get this to happen consistently.Trigger the go build error:
The errors refer to the source file at
/src/internal/dagger/dagger.gen.go
. However, the imports it's erroring on are not the actual imports in the source file:dagger/test/internal/
but the actual imports in the source code aredagger/bare/internal
dagger/test/internal
. So it seems likego build
here is somehow finding something in the cache from a previous build and incorrectly using it for this one.The error goes away if you first clear the build cache and then run the same
go build
command:What did you expect to see?
For
go build
to not report errors that don't correspond to the source contents, and for the go build cache to not need to be cleared in order to get rid of the errors.The text was updated successfully, but these errors were encountered: