-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: "mod tidy" tries to require the latest version of a replacement module #70137
Comments
Duplicate of #26904 |
Hi @seankhliao, thanks for reviewing this issue. Could you clarify why this is considered a duplicate of #26904? In #26904, the user module involved both the upstream and fork1, aiming to use fork2 as a replacement for both, with neither upstream nor fork1 containing a In this case, however, we only have the upstream |
Replace replaces source code, but doesn't rewrite import paths. meikg/dns is replaced by zmap/dns, but this replaced version of meikg/dns has imports that require zmap/zdns, that's are where your indirect dependency comes from. So zmap/dns is used as both the replacement and itself (required by the replacement). |
Thank you for the explanation! Sorry about the confusing names here, but I think To elaborate further, our user module
It’s only in the second Here's
|
Sorry, zmap/dns depends on zmap/dns (itself). |
Ah, I see what's going on now - thank you so much for your help! I don’t believe we actually use the Would having |
Go version
go version go1.21.1 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
Bump version for zmap/dns in this replace line to
v1.1.63
, then rungo mod tidy
https://github.com/zmap/zdns/pull/468/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R20
What did you see happen?
What did you expect to see?
go mod tidy
executes without errors.The issue arises when
tidy
attempts to pull the latest version of the replacement target module (zmap/dns
in this case) and includes it as an indirect requirement. When the replace target version is the latest version, the indirect require that tidy tries to add caused the above error.Adjusting the
replace
directive to a non-latest version - e.g.,replace github.com/miekg/dns => github.com/zmap/dns v1.1.62-zdns
as what we have in the referenced PR now - allowstidy
to complete without errors. However,tidy
will try to introduce an indirect requirement forv1.1.63
(latest), which I believe is also undesirable, as I specifically requested a version that is not the latest in thereplace
directive.I expected
go mod tidy
to respect whatever version specified inreplace
, and does not attempt to introduce the latest version as an indirect require.The text was updated successfully, but these errors were encountered: