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.
$ go-licenses check ./...
error discovering license for github.com/example/somemod:
cannot find a known license fileCommon 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
- Run
go mod downloadso every module (and its license file) is present. - Re-run go-licenses so it can read licenses from the cache.
- For a stubborn module, confirm it actually ships a LICENSE file.
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.
go-licenses check ./... \
--ignore github.com/example/somemodHow 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.