-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: go mod tidy
introduces ambiguous imports in pruned modules
#60313
Comments
Change https://go.dev/cl/496518 mentions this issue: |
This is related to #27899, but simpler in that it only requires preserving existing versions of modules (not upgrading to newer versions). |
Change https://go.dev/cl/496635 mentions this issue: |
For #60313. Change-Id: I76e48f52341e9962de9b809741a677d61baae6a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/496518 Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
@gopherbot, please backport to Go 1.19 and 1.20. This bug causes |
Backport issue(s) opened: #60351 (for 1.19), #60352 (for 1.20). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/499635 mentions this issue: |
Change https://go.dev/cl/499636 mentions this issue: |
Change https://go.dev/cl/502695 mentions this issue: |
Michael noticed some minor issues in backports of CL 496635. Those issues have been addressed in the backport CLs; this change applies them to the main branch as well. Updates #60313. Change-Id: If68696711a10a9270193df66ed551395c14cae00 Reviewed-on: https://go-review.googlesource.com/c/go/+/502695 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
…ports in 'go mod tidy' We don't normally keep explicit requirements for test dependencies of packages loaded from other modules when the required version is already the selected version in the module graph. However, in some cases we may need to keep an explicit requirement in order to make use of lazy module loading to disambiguate an otherwise-ambiguous import. Note that there is no Go version guard for this change: in the cases where the behavior of 'go mod tidy' has changed, previous versions of Go would produce go.mod files that break successive calls to 'go mod tidy'. Given that, I suspect that any existing user in the wild affected by this bug either already has a workaround in place using redundant import statements (in which case the change does not affect them) or is running 'go mod tidy -e' to force past the error (in which case a change in behavior to a non-error should not be surprising). Updates #60313. Fixes #60352. Change-Id: Idf294f72cbe3904b871290d79e4493595a0c7bfc Reviewed-on: https://go-review.googlesource.com/c/go/+/496635 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 2ed6a54) Reviewed-on: https://go-review.googlesource.com/c/go/+/499635 Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
…ports in 'go mod tidy' We don't normally keep explicit requirements for test dependencies of packages loaded from other modules when the required version is already the selected version in the module graph. However, in some cases we may need to keep an explicit requirement in order to make use of lazy module loading to disambiguate an otherwise-ambiguous import. Note that there is no Go version guard for this change: in the cases where the behavior of 'go mod tidy' has changed, previous versions of Go would produce go.mod files that break successive calls to 'go mod tidy'. Given that, I suspect that any existing user in the wild affected by this bug either already has a workaround in place using redundant import statements (in which case the change does not affect them) or is running 'go mod tidy -e' to force past the error (in which case a change in behavior to a non-error should not be surprising). Updates #60313. Fixes #60351. Change-Id: Idf294f72cbe3904b871290d79e4493595a0c7bfc Reviewed-on: https://go-review.googlesource.com/c/go/+/496635 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 2ed6a54) Reviewed-on: https://go-review.googlesource.com/c/go/+/499636 TryBot-Bypass: Bryan Mills <bcmills@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
I'm still seeing a similar issue when running
|
@RaghavSood, the |
I did try that by running the |
Do both the |
Only
|
Ah, then perhaps you don't have lazy module loading enabled? (Does your |
@bcmills could this maybe still be an issue in the transitive case?
But I expected the
|
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Clone vocdoni/census3@559b89d and
go mod tidy
it twice:What did you expect to see?
Both
go mod tidy
operations should succeed.What did you see instead?
The first
go mod tidy
succeeds, but it removes a requirement needed to prevent an ambiguous import in a test dependency of a transitively-imported package, causing the secondgo mod tidy
to fail:(CC @matloob)
Example courtesy of @mvdan.
The text was updated successfully, but these errors were encountered: