{"record":{"id":"a33907c8e59eda4a","repo":"golang/go","slug":"s-exists-with-wrong-content-have-q-want-q","errorCode":null,"errorMessage":"%s exists with wrong content (have %q want %q)","messagePattern":"(.+?) exists with wrong content \\(have %q want %q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/codehost/codehost.go","lineNumber":258,"sourceCode":"\n\tlockfile = dir + \".lock\"\n\tif buildX {\n\t\tfmt.Fprintf(xLog, \"# lock %s\\n\", lockfile)\n\t}\n\n\tunlock, err := lockedfile.MutexAt(lockfile).Lock()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"codehost.WorkDir: can't find or create lock file: %v\", err)\n\t}\n\tdefer unlock()\n\n\tdata, err := os.ReadFile(dir + \".info\")\n\tinfo, err2 := os.Stat(dir)\n\tif err == nil && err2 == nil && info.IsDir() {\n\t\t// Info file and directory both already exist: reuse.\n\t\thave := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif have != key {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"%s exists with wrong content (have %q want %q)\", dir+\".info\", have, key)\n\t\t}\n\t\tif buildX {\n\t\t\tfmt.Fprintf(xLog, \"# %s for %s %s\\n\", dir, typ, name)\n\t\t}\n\t\treturn dir, lockfile, nil\n\t}\n\n\t// Info file or directory missing. Start from scratch.\n\tif xLog != nil {\n\t\tfmt.Fprintf(xLog, \"mkdir -p %s # %s %s\\n\", dir, typ, name)\n\t}\n\tos.RemoveAll(dir)\n\tif err := os.MkdirAll(dir, 0777); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tif err := os.WriteFile(dir+\".info\", []byte(key), 0666); err != nil {\n\t\tos.RemoveAll(dir)\n\t\treturn \"\", \"\", err","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/codehost/codehost.go#L240-L276","documentation":"Thrown by codehost.WorkDir when the .info metadata file for a cached VCS checkout exists and the checkout directory exists, but the .info content (the key string 'type:name') does not match the computed key. This indicates the cache entry is stale, corrupted, or the hash function changed between go versions.","triggerScenarios":"Accessing a cached VCS repo after upgrading go (the key derivation or directory layout changed), after manual tampering with the cache, or after a filesystem corruption event.","commonSituations":"Downgrading or upgrading across major go versions that changed the cache layout; running 'go clean -cache' partially; disk corruption; copying a cache between machines with different architectures where the hash input differs.","solutions":["Clear the VCS cache: 'go clean -cache' or 'rm -rf $(go env GOMODCACHE)/cache/vcs'.","Retry the go command — it will re-clone fresh.","If recurring, check filesystem health (fsck/disk diagnostics).","Ensure only one go version writes to a given GOMODCACHE."],"exampleFix":"# before: stale .info from old go version\n$ go get example.com/mod\n... exists with wrong content ...\n# after\ngo clean -cache\ngo get example.com/mod","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use one go version per GOMODCACHE to avoid key-derivation mismatches.","Run 'go clean -cache' after major go version upgrades.","Don't manually edit files under GOMODCACHE/cache/vcs.","Don't copy cache directories between machines; let go rebuild them."],"tags":["cache","corruption","vcs-cache","version-mismatch"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}