Skip to content
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

Proposal: honor replace directives from imported modules in go.mod #39358

Open
enuoCM opened this issue Jun 2, 2020 · 3 comments
Open

Proposal: honor replace directives from imported modules in go.mod #39358

enuoCM opened this issue Jun 2, 2020 · 3 comments
Labels
Milestone

Comments

@enuoCM
Copy link

@enuoCM enuoCM commented Jun 2, 2020

gomod has following restriction:

exclude and replace directives only operate on the current (“main”) module. exclude and replace directives in modules other than the main module are ignored when building the main module. The replace and exclude statements, therefore, allow the main module complete control over its own build, without also being subject to complete control by dependencies.

This make it's hard and unreliable import other modules which have replace. For example, if the “main” module forgets to set related replace of other modules, bugs may happen.

In fact, even the replace is not ignored in modules, the "main" module can still complete control all dependencies by it's own replace. So it's better to not ignore replace directive of other modules.

More info please refer to #39310

@enuoCM enuoCM changed the title Propose: go.mode do not ignore replace directive of other modules Propose: go.mode does not ignore replace directive of other modules Jun 2, 2020
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jun 2, 2020

this goes against the design goals of go's version selection algorithm https://research.swtch.com/vgo-mvs

@enuoCM
Copy link
Author

@enuoCM enuoCM commented Jun 3, 2020

That's why this should be a new feature.
Is it just difficult to or can it not completely implement non-local replace?
At least for some kinds of replace, such as relative filesystem in other modules, forked dependency(which should be not conflicting usually), which should be not that difficult.
And at the very least,there should be some warnings if it ignores some non-local replace.

@toothrot
Copy link
Contributor

@toothrot toothrot commented Jun 8, 2020

Thanks for filing @enuoCM. @rsc has an excellent post describing why this is a difficult problem, and why Go made the decision to explicitly disallow this: https://research.swtch.com/vgo-mvs#replacing_modules

If you do intend on writing a proposal for this, it would need to address the concerns outlined in the design. One such concern is conflict resolution.

Previously #38665, #37261, #36205 (and many others).

@toothrot toothrot changed the title Propose: go.mode does not ignore replace directive of other modules Proposal: honor replace directives from imported modules in go.mod Jun 12, 2020
@gopherbot gopherbot added this to the Proposal milestone Jun 12, 2020
@gopherbot gopherbot added the Proposal label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.