Skip to content
Latchkey

Go "no required module provides package" - Fix in CI

Go found an import in your code but no module in go.mod provides it. Without a require directive it cannot resolve where the package comes from.

What this error means

A build fails with no required module provides package X; to add it: go get X. It means an import was added without recording the providing module, or the path is misspelled.

go
app/main.go:6:2: no required module provides package github.com/spf13/cobra;
	to add it:
	go get github.com/spf13/cobra

Common causes

Import added without a require

New code imports a package but go get / go mod tidy was never run to add the providing module.

Misspelled import path

The import path is wrong, so no real module matches and Go reports it as unprovided.

How to fix it

Add the providing module

  1. Run go get for the package, or go mod tidy to resolve every import at once.
  2. Commit go.mod and go.sum.
Terminal
go mod tidy
git add go.mod go.sum

Verify the import path

  1. Confirm the path matches the real module path on its host and fix any typo.
Terminal
go build ./...

How to prevent it

  • Run go mod tidy after adding any import.
  • Copy import paths from package docs to avoid typos.
  • Add a tidiness guard so missing requires fail CI early.

Frequently asked questions

What causes ""no required module provides package""?
New code imports a package but go get / go mod tidy was never run to add the providing module.
How do I fix "no required module provides package"?
Add the providing module

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card