Skip to content
Latchkey

Go "cannot find module providing package" - Fix in CI

You import a package, but no module in go.mod provides it. Either the dependency was never added with go get, the import path is wrong, or you are in module mode without the require it needs.

What this error means

A build fails with no required module provides package <path> and a hint to run go get. The code references a package, but the module graph has nothing that supplies that import path.

go output
app/main.go:5:2: no required module provides package
github.com/example/util; to add it:
	go get github.com/example/util

Common causes

Dependency not added to go.mod

The import was written but go get (or go mod tidy) was never run, so go.mod has no require line that provides the package.

Wrong or renamed import path

A typo, a moved repository, or a new major version path (/v2) means the import does not resolve to any real module.

GOFLAGS=-mod=vendor without a vendored copy

In vendor mode, a package missing from vendor/ cannot be found even though it exists upstream.

How to fix it

Add the dependency

Fetch the module that provides the import and record it in go.mod/go.sum.

Terminal
go get github.com/example/util
go mod tidy

Check the import path and major version

  1. Confirm the path matches the upstream repository exactly.
  2. For v2+ modules, the import path must include the major version suffix (/v2).
  3. If the repo moved, update the import to its new canonical path.

Vendor the dependency if you build with -mod=vendor

Terminal
go mod tidy
go mod vendor
go build -mod=vendor ./...

How to prevent it

  • Run go mod tidy so every import has a matching require.
  • Use the exact canonical import path, including the /vN major suffix.
  • Keep vendor/ regenerated when building in vendor mode.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →