go build_error ai_generated true

go: /path/to/project 中 vendoring 不一致:go.mod 要求 github.com/foo/bar v1.4.0 但 vendor/modules.txt 记录的是 v1.2.0

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

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-03-15首次发现

版本兼容性

版本状态引入弃用备注
1.14 active
1.21 active
1.24 active

根因分析

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

English

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

generic

解决方案

  1. 95% 成功率
    go mod vendor
  2. 90% 成功率
    go mod tidy && go mod vendor

无效尝试

常见但无效的做法:

  1. 95% 失败

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

  2. 80% 失败

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