go build_error ai_generated true

go: /path/to/module 中的 vendor 不一致: github.com/foo/[email protected]: 在 go.mod 中显式 require,但在 vendor/modules.txt 中未标记为 explicit

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

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

版本兼容性

版本状态引入弃用备注
1.16+ active — — —
1.21+ active — — —

根因分析

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

English

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

generic

解决方案

  1. 97% 成功率
    go mod tidy
    go mod vendor
    go build -mod=vendor ./...
  2. 85% 成功率
    go build -mod=mod ./...

无效尝试

常见但无效的做法:

  1. 85% 失败

    vendor contents still mismatch; next build fails differently

  2. 70% 失败

    CI configured for vendored builds fails with missing vendor dir

  3. 50% 失败

    ignores vendor but CI may still require vendoring