go build_error ai_generated true

go: inconsistent vendoring in /path/to/module: github.com/foo/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

ID: go/inconsistent-vendoring

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-05-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.16+ active — — —
1.21+ active — — —

Root Cause

The vendor/ directory is stale relative to go.mod/go.sum. Common after editing dependencies without re-running go mod vendor.

generic

中文

vendor/ 目录相对于 go.mod/go.sum 已过期。常见于修改依赖后未重新运行 go mod vendor。

Workarounds

  1. 97% success
    go mod tidy
    go mod vendor
    go build -mod=vendor ./...
  2. 85% success
    go build -mod=mod ./...

Dead Ends

Common approaches that don't work:

  1. 85% fail

    vendor contents still mismatch; next build fails differently

  2. 70% fail

    CI configured for vendored builds fails with missing vendor dir

  3. 50% fail

    ignores vendor but CI may still require vendoring