{"record":{"id":"f739fb167c0bcc43","repo":"golang/go","slug":"reading-s-v-f739fb","errorCode":null,"errorMessage":"reading %s: %v","messagePattern":"reading (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/modfile.go","lineNumber":805,"sourceCode":"\t\tif !filepath.IsAbs(dir) {\n\t\t\tif ld.inWorkspaceMode() && ld.MainModules.Contains(m.Path) {\n\t\t\t\tdir = ld.MainModules.ModRoot(m)\n\t\t\t} else {\n\t\t\t\t// m is a replacement module with only a file path.\n\t\t\t\tdir = filepath.Join(replaceRelativeTo(ld), dir)\n\t\t\t}\n\t\t}\n\t\tname = filepath.Join(dir, \"go.mod\")\n\t\tif fsys.Replaced(name) {\n\t\t\t// Don't lock go.mod if it's part of the overlay.\n\t\t\t// On Plan 9, locking requires chmod, and we don't want to modify any file\n\t\t\t// in the overlay. See #44700.\n\t\t\tdata, err = os.ReadFile(fsys.Actual(name))\n\t\t} else {\n\t\t\tdata, err = lockedfile.Read(name)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn \"\", nil, module.VersionError(m, fmt.Errorf(\"reading %s: %v\", base.ShortPath(name), err))\n\t\t}\n\t} else {\n\t\tif !gover.ModIsValid(m.Path, m.Version) {\n\t\t\t// Disallow the broader queries supported by fetch.Lookup.\n\t\t\tbase.Fatalf(\"go: internal error: %s@%s: unexpected invalid semantic version\", m.Path, m.Version)\n\t\t}\n\t\tname = \"go.mod\"\n\t\tdata, err = ld.Fetcher().GoMod(context.TODO(), m.Path, m.Version)\n\t}\n\treturn name, data, err\n}\n\n// queryLatestVersionIgnoringRetractions looks up the latest version of the\n// module with the given path without considering retracted or excluded\n// versions.\n//\n// If all versions of the module are replaced,\n// queryLatestVersionIgnoringRetractions returns the replacement without making","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/modfile.go#L787-L823","documentation":"Returned from rawGoModData when reading the go.mod bytes for a module fails at the I/O layer. For versioned modules this wraps an error from the module proxy/fetcher GoMod() call; for a filesystem replacement (m.Version==\"\") it wraps a lockedfile.Read / os.ReadFile failure on the local go.mod path. Wrapped in module.VersionError to name the module.","triggerScenarios":"A replacement directive points at a local directory whose go.mod is missing or unreadable; the module proxy is unreachable or returns an error for the go.mod endpoint; permission denied on the cached file; the replacement path is relative and resolves incorrectly.","commonSituations":"replace directive with a wrong or non-existent local path; GOPROXY misconfigured or down; filesystem permissions block reading vendor/cache; relative replacement path evaluated from the wrong working directory.","solutions":["For a local replacement, verify the path exists and contains a go.mod: 'ls <replacePath>/go.mod'.","Fix GOPROXY/GONOSUMCHECK/network so the proxy can serve remote go.mod files.","Check file permissions on the module cache and the replacement directory.","Use an absolute path in the replace directive to avoid working-directory ambiguity."],"exampleFix":"// before\nreplace example.com/pkg => ./pkg   // ./pkg/go.mod missing\n// error: reading ./pkg/go.mod: no such file or directory\n\n// after\nreplace example.com/pkg => ./pkghas   // directory that contains go.mod","handlingStrategy":"validation","validationCode":"// For local replacements, confirm the file exists before building:\n//   if _, err := os.Stat(filepath.Join(replaceDir, \"go.mod\")); err != nil { /* fix path */ }","typeGuard":"func replaceGoModExists(dir string) bool {\n    _, err := os.Stat(filepath.Join(dir, \"go.mod\"))\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Use absolute paths in replace directives to avoid working-directory ambiguity.","Add a CI step that runs 'go mod download' to surface unreachable proxies/paths.","Document replacement targets so contributors do not delete the referenced directories."],"tags":["go-modules","io","replace","filesystem","proxy"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}