Skip to content
Latchkey

go-licenses "error discovering license" in CI

go-licenses could not find or classify the license file for a module (or could not build the license URL), so it reported an error discovering the license and stopped instead of returning a clean result.

What this error means

The command errors mid-run with a message about being unable to find a license for a specific module path, often for modules with no LICENSE file at the expected location or a vendored/replaced module.

Terminal
$ go-licenses check ./...
error discovering license for github.com/example/somemod:
  cannot find a known license file

Common causes

The module has no recognizable license file

go-licenses looks for a LICENSE-style file in the module; a module that puts its license in an unusual place, or has none, cannot be classified.

The module cache or vendoring is incomplete

If modules are not fully downloaded (or a replace points somewhere without the license), the tool cannot read the license from disk.

How to fix it

Populate the module cache first

  1. Run go mod download so every module (and its license file) is present.
  2. Re-run go-licenses so it can read licenses from the cache.
  3. For a stubborn module, confirm it actually ships a LICENSE file.
Terminal
go mod download
go-licenses report ./...

Ignore a package that cannot be classified

For a module you have vetted manually, use --ignore to skip it so discovery does not abort the whole run.

Terminal
go-licenses check ./... \
  --ignore github.com/example/somemod

How to prevent it

  • Download modules before running go-licenses in CI.
  • Keep a small, reviewed ignore list for modules with unusual license layouts.
  • Avoid replace directives that point at trees without license files.

Frequently asked questions

What causes "go-licenses discovery error"?
go-licenses looks for a LICENSE-style file in the module; a module that puts its license in an unusual place, or has none, cannot be classified.
How do I fix go-licenses discovery error?
Populate the module cache first

Related guides

References

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