Go "inconsistent vendoring; run go mod vendor" - Fix in CI
When a vendor/ directory exists, Go builds from it and checks vendor/modules.txt against go.mod. If the two disagree, the build refuses rather than guess which is right.
What this error means
A build fails with inconsistent vendoring listing modules that differ between go.mod and vendor/modules.txt, ending with a go mod vendor hint. It means the vendor tree was not regenerated after a go.mod change.
go
go: inconsistent vendoring in /home/runner/work/app:
github.com/foo/bar@v1.2.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
To sync the vendor directory, run:
go mod vendorCommon causes
vendor tree not regenerated
go.mod changed but go mod vendor was never re-run, so vendor/modules.txt is stale.
Partial vendor commit
Some vendored files or modules.txt were omitted from the commit, leaving the tree internally inconsistent.
How to fix it
Regenerate and commit the vendor tree
- Run go mod vendor to rebuild vendor/ and vendor/modules.txt from go.mod.
- Stage the entire vendor directory plus modules.txt and commit.
Terminal
go mod vendor
git add vendor go.mod go.sumVerify the vendor tree in CI
- Re-run go mod vendor and fail if it changes anything under vendor/.
.github/workflows/ci.yml
go mod vendor
git diff --exit-code vendorHow to prevent it
- Re-run
go mod vendorafter any go.mod change. - Commit the whole vendor/ tree, not a subset.
- Add a
git diff --exit-code vendorguard to CI.
Related guides
Go "missing go.sum entry; to add it run go mod download" - Fix in CIFix Go "missing go.sum entry for module; to add it, run go mod download" in CI - go.sum lacks a checksum the…
Go "updates to go.mod needed, disabled by -mod=mod" - Fix in CIFix Go "updates to go.mod needed, disabled by -mod=..." in CI - a readonly build found a change the committed…
Go GOFLAGS=-mod=readonly conflict - Fix in CIFix Go GOFLAGS=-mod=readonly conflicting with a command that needs -mod=mod in CI - readonly blocks the go.mo…