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

Dependency solving incorrect edge case behaviour in hook context #2543

Closed
JeroenDeDauw opened this issue Jan 2, 2014 · 10 comments
Closed

Dependency solving incorrect edge case behaviour in hook context #2543

JeroenDeDauw opened this issue Jan 2, 2014 · 10 comments
Labels

Comments

@JeroenDeDauw
Copy link

I am seeing some odd behaviour in the dependency solving after programatically adding a provides link via the pre-update-cmd hook.

My code can be found at https://gerrit.wikimedia.org/r/#/c/105092/

I am observing that:

  • ~1.23 is not satisfied by 1.23 (wrong)
  • ~1.23 is satisfied by 1.23.1 or 1.24 (correct)
  • ~1.23 is satisfied by 1.24-alpha without decreasing min stability (wrong)
  • ~1.23@alpha is not satisfied by 1.23-alpha (wrong)
@Seldaek
Copy link
Member

Seldaek commented Jan 2, 2014

  • ~1.23 is not satisfied by 1.23 (wrong) => pretty sure that's a mistake on your end somehow
  • ~1.23 is satisfied by 1.23.1 or 1.24 (correct) => all good
  • ~1.23 is satisfied by 1.24-alpha without decreasing min stability (wrong) => 1.24-alpha satisfies ~1.23 for sure, but it should be ignored by the Pool if alpha packages aren't allowed. I couldn't for the life of me figure out a way to get a diff out of this gerrit monster though :/ So not sure what you are up to that could cause this to fail.
  • ~1.23@alpha is not satisfied by 1.23-alpha (wrong) => that is correct behavior, 1.23-alpha comes before 1.23 stable, which is where ~1.23 starts. @alpha just denotes that alpha packages are allowed in the range, but you really want to be using ~1.23-alpha or ~1.23-dev to include all pre-release variants. In most practical cases though this is not really needed because the pre-release branch typically would have a 1.23.x-dev alias or something which resolves as 1.23.999999.999999-dev which is higher than 1.23.0.0 (the beginning of the ~1.23 range).

@JeroenDeDauw
Copy link
Author

I couldn't for the life of me figure out a way to get a diff out of this gerrit monster though :/

Diff on GitHub

that is correct behavior, 1.23-alpha comes before 1.23 stable, which is where ~1.23 starts

Thanks for clarifying!

1.24-alpha satisfies ~1.23 for sure, but it should be ignored by the Pool if alpha packages aren't allowed.

Well, by default they are not allowed right? One has to set the minimum-stability flag no? I did not set it.

pretty sure that's a mistake on your end somehow

That was my first thought as well, though if that is indeed the case, I could not find the mistake. This is the error I am getting:

mediawiki/sub-page-list2 dev-master requires mediawiki/mediawiki ~1.23.0 -> no matching package found.

This is the link added as "provide":

class Composer\Package\Link#413 (5) {
  protected $source =>
  string(8) "__root__"
  protected $target =>
  string(19) "mediawiki/mediawiki"
  protected $constraint =>
  class Composer\Package\LinkConstraint\VersionConstraint#412 (3) {
    private $operator =>
    string(2) "=="
    private $version =>
    string(6) "1.23.0"
    protected $prettyString =>
    string(8) "1.23.0.0"
  }
  protected $description =>
  string(8) "provides"
  protected $prettyConstraint =>
  string(8) "1.23.0.0"
}

@stof
Copy link
Contributor

stof commented Jan 3, 2014

~1.23.0 is not the same as ~1.23. 1.24 will match the second constraint, but not the first one

@Seldaek
Copy link
Member

Seldaek commented Jan 3, 2014

Well, by default they are not allowed right? One has to set the minimum-stability flag no? I did not set it.

Indeed, but anyway we would need to see the complete composer.json to be able to tell. And given you're hacking things together at a fairly low level unexpected side effects can not be excluded.

@JeroenDeDauw
Copy link
Author

~1.23.0 is not the same as ~1.23. 1.24 will match the second constraint, but not the first one

I'm well aware of this. This is definitely not what I am running into.

Indeed, but anyway we would need to see the complete composer.json to be able to tell.

The composer.json of my root package looks as follows: http://pastebin.com/V4xfDJZ3

That is of course without the actual "provides" link, as this one gets added programatically. The composer.json of the sub-page-list thing is http://pastebin.com/YPZw2Sve

And given you're hacking things together at a fairly low level unexpected side effects can not be excluded.

Well yeah. I am only seeing the behaviour in the context of this hook, hence the title of the bug.

that is correct behavior, 1.23-alpha comes before 1.23 stable, which is where ~1.23 starts

Now I understand that correctly, I am observing the following incorrect behaviour as well:

  • ~1.23-alpha is not satisfied by 1.23-alpha
  • 1.23-alpha is not satisfied by 1.23-alpha

@stof
Copy link
Contributor

stof commented Jan 3, 2014

what is the provide you are adding exactly ?

@JeroenDeDauw
Copy link
Author

what is the provide you are adding exactly?

See the var_dump output I posted in this comment.

@stof
Copy link
Contributor

stof commented Jan 3, 2014

you inverted the prettyString and the normalized version in your constraint. the version is not normalized in your object, which is probably why the version comparison goes weird

@JeroenDeDauw
Copy link
Author

you inverted the prettyString and the normalized version in your constraint.

Ugh. Thanks :) Those damned primitives, so easy to mix up!

This fixed the behaviour, so this was an issue with my code. https://gerrit.wikimedia.org/r/#/c/105092/7..8/includes/ComposerPackageModifier.php

@Seldaek
Copy link
Member

Seldaek commented Jan 3, 2014

@JeroenDeDauw eh sorry I know this is hard to dive into :) Glad it's fixed now though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants