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

x/exp/cmd/gorelease: main module should not require newer version of itself #37567

Closed
jayconrod opened this issue Feb 28, 2020 · 7 comments
Closed
Labels
FeatureRequest FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@jayconrod
Copy link
Contributor

Suppose that module example.com/main requires example.com/a@v1.0.0, which requires example.com/main@v1.5.0. gorelease should report an error when run on example.com/main with a proposed version lower than v1.5.0. A lower version will not be usable, since MVS will always upgrade the module to a higher version.

@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. FeatureRequest modules Tools This label describes issues relating to any tools in the x/tools repository. labels Feb 28, 2020
@jayconrod jayconrod added this to the Unreleased milestone Feb 28, 2020
@ackFacu
Copy link

ackFacu commented Apr 18, 2020

I think this is not supposed to work, independent of the version. This is a cyclic dependency, and golang doesn't support that as far as I know.

@jayconrod
Copy link
Contributor Author

Go allows cyclic dependencies in modules, just not packages.

@jayconrod jayconrod modified the milestones: Unreleased, gorelease Oct 14, 2020
@jeanbza
Copy link
Member

jeanbza commented Nov 25, 2020

Can I suggest a new title?

"x/exp/cmd/gorelease: when main module has cycle to itself, only allow versions greater than latest in cycle"

Or, something to that affect? The current title and description don't seem to match: the title says "cycles are not allowed", the description says "cycles are allowed but version has to be greater than greatest in cycle".

@gopherbot
Copy link

Change https://golang.org/cl/273288 mentions this issue: x/exp/cmd/gorelease: when main module has cycle to itself, only allow versions

@jeanbza
Copy link
Member

jeanbza commented Nov 25, 2020

Thoughts after looking into this for a while:

  • Ignore if v0
  • Else,
    1. go mod graph
    2. Look for same module path
    3. Throw away versions not in same major as suggested
    4. Get latest
    5. See if suggested > latest, report err if not

Does that sound about right @jayconrod ?

@jayconrod
Copy link
Contributor Author

@jadekler I don't think that's quite right: it's okay if a module requires a lower version of itself; a higher version should be an error though.

For example, suppose we're running gorelease in module A with -version=v0.5.0. A requires B at v0.1.0, and B requires A at v0.6.0. That should be an error because if anyone requires module A at v0.5.0, they'll get v0.6.0 instead because A v0.5.0 transitively requires a higher version of itself. So the v0.5.0 won't be usable. It would be okay if B required A at v0.4.0 instead, or if we were preparing to tag A v0.6.1.

The approach you outlined should work except the condition at the end needs to be flipped. Also, this should apply at all major versions including v0.

@jeanbza
Copy link
Member

jeanbza commented Dec 1, 2020

Also, this should apply at all major versions including v0.

SG!


Rewriting step v in more clear logic:

// version == suggested or requested version
if version < latestVersion {
  // report err
}

For example, suppose we're running gorelease in module A with -version=v0.5.0. A requires B at v0.1.0, and B requires A at v0.6.0. That should be an error because if anyone requires module A at v0.5.0, they'll get v0.6.0 instead because A v0.5.0 transitively requires a higher version of itself. [...]

The approach you outlined should work except the condition at the end needs to be flipped.

Logic above seems to hold, AFAICT? version = v0.5.0, latestVersion = v0.6.0, version < latestVersion == true so we err.

Probably missing something though - please let me know if I am!

@golang golang locked and limited conversation to collaborators Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants