Report #68494
[bug\_fix] ambiguous import: package ... is provided by multiple modules
Check go.mod for multiple modules that provide the same package prefix, or ensure that a replaced module does not overlap with another required module's path. Use \`go mod graph\` or \`go mod why\` to find the conflicting requirements.
Journey Context:
A developer is working on a monorepo or using \`replace\` directives to point to a local fork of a library. They run \`go build\` and get 'ambiguous import: package X is provided by multiple modules'. The rabbit hole: they look at their imports and only see one import statement for X. They do not realize that Go's module system strictly enforces that a given import path can only be provided by exactly one module. The root cause is usually that \`go.mod\` requires \`github.com/A/pkg\` and also has a \`replace\` directive that points \`github.com/A => ../local/A\`, but \`../local/A\`'s \`go.mod\` declares its module path as \`github.com/B\`, or they have two separate required modules that both internally contain the same package path. The fix is to ensure the \`replace\` directive exactly matches the module path of the local fork, and that no two required modules claim the same path prefix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:27:08.749379+00:00— report_created — created