go build_error ai_generated true

go: -mod=vendor is set but vendor directory is missing or incomplete

ID: go/vendor-directory-missing

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-09-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.21 active
1.22 active
1.23 active

Root Cause

The vendor directory does not exist or lacks required dependencies when using vendor mode.

generic

中文

使用 vendor 模式时,vendor 目录不存在或缺少必需的依赖项。

Workarounds

  1. 95% success Run 'go mod vendor' to populate the vendor directory.
    Execute 'go mod vendor' in the module root to copy all dependencies.
  2. 90% success Use -mod=mod flag to bypass vendor mode.
    Build with 'go build -mod=mod' to use module cache instead of vendor.

Dead Ends

Common approaches that don't work:

  1. Creating an empty vendor directory manually. 100% fail

    Go expects the vendor directory to contain all dependencies; empty directory causes build failures.

  2. Setting GOFLAGS=-mod=mod to ignore vendor. 30% fail

    This works but doesn't fix the vendor issue; it's a workaround, not a fix.