golang/go · error

%s is missing module path%s at revision %s

Error message

%s is missing module path%s at revision %s

What it means

findDir (coderepo.go:887-895). The root go.mod (file1) was read successfully (err1 == nil) but found1 is false AND mpath1 is empty. found1 false means the major version did not match; the inner check `mpath1 == ""` then reports that the root go.mod has no module directive at all. The optional suffix notes whether the major-subdir go.mod was also missing.

Source

Thrown at src/cmd/go/internal/modfetch/coderepo.go:894

				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)
		}
		if r.pathMajor != "" { // ".v1", ".v2" for gopkg.in
			return "", "", nil, fmt.Errorf("%s has non-...%s module path %q%s at revision %s", file1, r.pathMajor, mpath1, suffix, rev)
		}
		if _, _, ok := module.SplitPathVersion(mpath1); !ok {
			return "", "", nil, fmt.Errorf("%s has malformed module path %q%s at revision %s", file1, mpath1, suffix, rev)
		}
		return "", "", nil, fmt.Errorf("%s has post-%s module path %q%s at revision %s", file1, semver.Major(version), mpath1, suffix, rev)
	}

	if r.codeDir == "" && (r.pathMajor == "" || strings.HasPrefix(r.pathMajor, ".")) {
		// Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in.
		return rev, "", nil, nil
	}

	// Implicit go.mod below root of repo or at v2+ disallowed.
	// Be clear about possibility of using either location for v2+.
	if file2 != "" {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Add a `module <path>` directive to the root go.mod in the source repo.
  2. If the module is meant to live in a major subdirectory, remove the bogus root go.mod so file2 is used.
  3. Tag a corrected revision and update the dependency.

Example fix

// before: go.mod
//   go 1.21

// after: go.mod
//   module example.com/m
//
//   go 1.21
Defensive patterns

Strategy: validation

Validate before calling

// Same lint as 993 applied to the root go.mod.
// bash:
//   grep -qE '^module ' go.mod || echo 'root go.mod missing module directive'
// Go:
//   if modfile.ModulePath(gomod1) == "" { return errors.New("missing module path") }

Prevention

When it happens

Trigger: A root go.mod exists at the revision but contains no `module` line (modfile.ModulePath returns ""). Common with stub go.mod files committed for tooling purposes.

Common situations: Committed go.mod with only `go 1.21` and no module directive; partially migrated legacy repos; go.mod generated by an IDE that omitted the module line.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/5cacf97c716d17c1. Report an issue: GitHub.