go build_error ai_generated true

go: inconsistent vendoring in /path/to/project: go.mod requires github.com/foo/bar v1.4.0 but vendor/modules.txt has v1.2.0

ID: go/module-graph-version-conflict

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.14 active
1.21 active
1.24 active

Root Cause

Vendor directory is out of sync with go.mod after updating a dependency version but not re-running 'go mod vendor'.

generic

中文

更新依赖版本后未重新运行 'go mod vendor',导致 vendor 目录与 go.mod 不同步。

Workarounds

  1. 95% success
    go mod vendor
  2. 90% success
    go mod tidy && go mod vendor

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Vendor directory contains actual source code and checksums; manual edits cause more inconsistencies and build failures.

  2. 80% fail

    If the project is configured for vendoring (with -mod=vendor), removing it causes 'cannot find module' errors unless you switch to network mode.