golang/go · error
%s/%s is missing module path at revision %s
Error message
%s/%s is missing module path at revision %s
What it means
findDir (coderepo.go:874-877). The major-subdir go.mod (file2) was read successfully (err2 == nil) but modfile.ModulePath returned an empty string — the file has no `module` directive. Without a declared module path the file cannot be validated for the expected major version.
Source
Thrown at src/cmd/go/internal/modfetch/coderepo.go:876
// a replace directive.
dir2 := path.Join(r.codeDir, r.pathMajor[1:])
file2 = path.Join(dir2, "go.mod")
gomod2, err2 := r.code.ReadFile(ctx, rev, file2, codehost.MaxGoMod)
if err2 != nil && !os.IsNotExist(err2) {
return "", "", nil, fmt.Errorf("reading %s/%s at revision %s: %v", r.codeRoot, file2, rev, err2)
}
mpath2 := modfile.ModulePath(gomod2)
found2 := err2 == nil && isMajor(mpath2, r.pathMajor)
if found1 && found2 {
return "", "", nil, fmt.Errorf("%s/%s and ...%s/go.mod both have ...%s module paths at revision %s", r.pathPrefix, file1, r.pathMajor, r.pathMajor, rev)
}
if found2 {
return rev, dir2, gomod2, nil
}
if err2 == nil {
if mpath2 == "" {
return "", "", nil, fmt.Errorf("%s/%s is missing module path at revision %s", r.codeRoot, file2, rev)
}
return "", "", nil, fmt.Errorf("%s/%s has non-...%s module path %q at revision %s", r.codeRoot, file2, r.pathMajor, mpath2, rev)
}
}
// Not v2/go.mod, so it's either go.mod or nothing. Which is it?
if found1 {
// Explicit go.mod with matching major version ok.
return rev, r.codeDir, gomod1, nil
}
if err1 == nil {
// Explicit go.mod with non-matching major version disallowed.
suffix := ""
if file2 != "" {
suffix = fmt.Sprintf(" (and ...%s/go.mod does not exist)", r.pathMajor)
}
if mpath1 == "" {
return "", "", nil, fmt.Errorf("%s is missing module path%s at revision %s", file1, suffix, rev)View on GitHub (pinned to b6b368adc5)
Solutions
- Open the offending go.mod in the source repo and add a proper `module <path>` directive.
- Remove the file if the major-subdir layout is not intended (let the root go.mod win).
- Re-tag and update the dependency version.
Example fix
// before: v2/go.mod // go 1.21 // after: v2/go.mod // module example.com/m/v2 // // go 1.21
Defensive patterns
Strategy: validation
Validate before calling
// Lint: every committed go.mod must have a module directive.
// bash:
// find . -name go.mod -print0 | xargs -0 -I{} sh -c 'grep -qE "^module " "{}" || echo "missing module: {}"'
// Go:
// path, err := modfile.Parse(...) // ensure Module.Path != "" Prevention
- Always include a `module` directive when creating go.mod.
- Add a pre-commit hook that rejects go.mod files without a module path.
- Run `go mod tidy` after editing go.mod to catch structural problems.
When it happens
Trigger: A /v2/go.mod exists in the repo but is empty, malformed at the top, or simply lacks a `module` line. modfile.ModulePath returns "" for files missing the directive.
Common situations: Placeholder go.mod committed by mistake; partially generated go.mod; the file was truncated during a mirror sync; go.mod written as a Go directive without the keyword.
Related errors
- %s is missing module path%s at revision %s
- %s/%s and ...%s/go.mod both have ...%s module paths at revis
- %s/%s has non-...%s module path %q at revision %s
- %s has non-...%s module path %q%s at revision %s
- %s has malformed module path %q%s at revision %s
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/982350262a50e9c2.
Report an issue: GitHub.