{"record":{"id":"9538fd46bf5b9f91","repo":"golang/go","slug":"loading-compiled-go-files-from-cache-w","errorCode":null,"errorMessage":"loading compiled Go files from cache: %w","messagePattern":"loading compiled Go files from cache: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/exec.go","lineNumber":780,"sourceCode":"\tvar srcfiles []string // .go and non-.go\n\tsrcfiles = append(srcfiles, gofiles...)\n\tsrcfiles = append(srcfiles, sfiles...)\n\tsrcfiles = append(srcfiles, cfiles...)\n\tb.cacheSrcFiles(a, srcfiles)\n\n\t// Sanity check only, since Package.load already checked as well.\n\tif len(gofiles) == 0 {\n\t\treturn &load.NoGoError{Package: p}\n\t}\n\n\t// Prepare Go vet config if needed.\n\tif need&needVet != 0 {\n\t\tbuildVetConfig(a, srcfiles, a.Deps)\n\t\tneed &^= needVet\n\t}\n\tif need&needCompiledGoFiles != 0 {\n\t\tif err := b.loadCachedCompiledGoFiles(a); err != nil {\n\t\t\treturn fmt.Errorf(\"loading compiled Go files from cache: %w\", err)\n\t\t}\n\t\tneed &^= needCompiledGoFiles\n\t}\n\tif need == 0 {\n\t\t// Nothing left to do.\n\t\treturn nil\n\t}\n\n\t// Collect symbol ABI requirements from assembly.\n\tsymabis, err := BuildToolchain.symabis(b, a, sfiles)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Prepare Go import config.\n\t// We start it off with a comment so it can't be empty, so icfg.Bytes() below is never nil.\n\t// It should never be empty anyway, but there have been bugs in the past that resulted\n\t// in empty configs, which then unfortunately turn into \"no config passed to compiler\",","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/exec.go#L762-L798","documentation":"When a package action needs compiled Go files (needCompiledGoFiles flag set, used for export data / inlining) and the build cache should have them, b.loadCachedCompiledGoFiles is called to retrieve them. If that returns an error — cache miss after a hit was promised, corrupt cache entry, or a stale .a — it's wrapped with this message and returned, failing the build.","triggerScenarios":"Building a package whose compiled export is expected from cache but the cache entry is missing/corrupt. Happens after 'go clean -cache' partial runs, concurrent cache eviction, or a cache shared across incompatible toolchains.","commonSituations":"GOCACHE corrupted by a crash mid-write; mixing GOCACHE across Go versions; cache on a network filesystem with consistency issues; disk full when the .a was written.","solutions":["Run 'go clean -cache' to invalidate the corrupt entry.","Ensure GOCACHE is local (not NFS/network) and on a writable volume with free space.","Use one GOCACHE per Go version to avoid cross-version cache corruption.","Re-run the build — a fresh compile repopulates the cache."],"exampleFix":"// before\n$ go build ./...\n// error: loading compiled Go files from cache: ... corrupt export data\n\n// after\n$ go clean -cache\n$ export GOCACHE=$HOME/.cache/go-build\n$ go build ./...","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// On cache-load failures, reset the cache and rebuild.\nif err := build(); err != nil && strings.Contains(err.Error(), \"loading compiled Go files from cache\") {\n    goCleanCache()\n    err = build()\n}","preventionTips":["Run 'go clean -cache' after Go toolchain upgrades.","Don't share one GOCACHE across Go versions or hosts.","Keep GOCACHE on reliable local storage."],"tags":["build","build-cache","io","export-data"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}