golang/go · critical
not in workspace mode but number of indexes is %v, not 1
Error message
not in workspace mode but number of indexes is %v, not 1
What it means
This is a panic, not a returned error. checkVendorConsistency panics when it is not in workspace mode yet receives more (or fewer) than one modFileIndex. In single-module mode exactly one index is expected; any other count means an internal invariant of the loader was violated.
Source
Thrown at src/cmd/go/internal/modload/vendor.go:159
// go 1.14) or at least does not contradict (go 1.13 or earlier) the
// requirements and replacements listed in the main module's go.mod file.
func checkVendorConsistency(ld *Loader, indexes []*modFileIndex, modFiles []*modfile.File) {
// readVendorList only needs the main module to get the directory
// the vendor directory is in.
readVendorList(VendorDir(ld))
if len(modFiles) < 1 {
// We should never get here if there are zero modfiles. Either
// we're in single module mode and there's a single module, or
// we're in workspace mode, and we fail earlier reporting that
// "no modules were found in the current workspace".
panic("checkVendorConsistency called with zero modfiles")
}
pre114 := false
if !ld.inWorkspaceMode() { // workspace mode was added after Go 1.14
if len(indexes) != 1 {
panic(fmt.Errorf("not in workspace mode but number of indexes is %v, not 1", len(indexes)))
}
index := indexes[0]
if gover.Compare(index.goVersion, "1.14") < 0 {
// Go versions before 1.14 did not include enough information in
// vendor/modules.txt to check for consistency.
// If we know that we're on an earlier version, relax the consistency check.
pre114 = true
}
}
vendErrors := new(strings.Builder)
vendErrorf := func(mod module.Version, format string, args ...any) {
detail := fmt.Sprintf(format, args...)
if mod.Version == "" {
fmt.Fprintf(vendErrors, "\n\t%s: %s", mod.Path, detail)
} else {
fmt.Fprintf(vendErrors, "\n\t%s@%s: %s", mod.Path, mod.Version, detail)
}View on GitHub (pinned to b6b368adc5)
Solutions
- This indicates a Go toolchain bug — report at https://go.dev/issue with the panic stack and reproduction.
- As a workaround, switch into or out of workspace mode explicitly ('go work' usage) to see if it changes the index count.
- Run 'go clean -modcache' and 'rm vendor/modules.txt' then 'go mod vendor' to rebuild vendor state.
Defensive patterns
Strategy: validation
Validate before calling
// Not user-preventable. Sanity-check loader state in tooling before calling vendor checks:
// if !ld.inWorkspaceMode() && len(indexes) != 1 { panic("loader invariant violated") } Prevention
- Treat this panic as a toolchain bug; report it with a reproduction at https://go.dev/issue.
- Keep vendor/modules.txt in sync by running 'go mod vendor' after dependency changes.
- Avoid mixing workspace and non-workspace invocations in the same process.
When it happens
Trigger: Vendor consistency checking runs outside workspace mode but the loader hands it a number of indexes != 1. Reachable only through a bug in loader state management or a malformed invocation path.
Common situations: Not user-triggered in normal operation. Could surface from experimental toolchain builds, corrupted build state, or a regression in cmd/go that mis-counts modules outside workspace mode.
Related errors
- internal error: main module version is not allowed: %w
- internal error: package %s is in the main module (%s), but v
- internal error: MatchPackages: %s is not a valid package pat
- internal error: MatchDirs: %s is not a valid filesystem patt
- bufio: reader returned negative count from Read
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/929be495abc8fd67.
Report an issue: GitHub.