-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
add --prefer-lowest and --prefer-stable to update command #3450
Conversation
@naderman there is a protected method |
@stof used to be a helper method for selectPreferedPackages, I'll delete it as it's no longer used. |
Please tell me if I should do anything before merge |
hmm, adding an integration test covering this case to ensure it works ? |
@@ -697,10 +698,14 @@ private function createPolicy() | |||
// old lock file without prefer stable will return null | |||
// so in this case we use the composer.json info | |||
if (null === $preferStable) { | |||
$preferStable = $this->package->getPreferStable(); | |||
if (getenv('COMPOSER_PREFER_LOWEST_STABLE')) { | |||
$preferStable = $preferLowest = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure about $preferStable
being true ? this would prefer a 2.4.0 over a 2.4.0-beta release, while 2.4.0 is lowest.
I think it should rather force $preferStable
to false, so that only the version ordering is used to find the selected version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I meant, currently it's called LOWEST_STABLE so that makes sense, but maybe we should support both LOWEST and LOWEST_STABLE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I tried without prefer-stable, and I went back in -rc1
or -alpha
state, which is certainly not what I'll ever want to test. So, if the only use case of this is testing the lowest version you pretend to support, I'm not sure that anyone will go up to supporting alpha nor even beta versions.
c632c7f
to
b6b4949
Compare
I just added a small unit test. For the integration test, there is none for other ENV vars... |
well other env vars have a config equivalent, this does not? |
This should probably also somehow use the new getComposerEnv() to avoid accidentally influencing test behavior with environment variables set in the process. https://github.com/composer/composer/blob/master/src/Composer/Config.php#L306 |
b6b4949
to
be8282c
Compare
Rebased to use |
Yes I didn't mean to ask for one, just meant that's why there probably aren't env tests for the others? |
43d4b3a
to
0fa6e79
Compare
I added a line in the travis-ci matrix so that composer itself is tested with its lowest deps. |
fb0b747
to
0dafd11
Compare
In fact, while trying to correctly test composer with the new flag, I've been hit by the same problem as in #3448 So, I replaced the env var by an option on the update command. |
Err I understood all of that except why you had to remove phpunit from require-dev? |
It's because tests do not pass: phpunit itself is broken when setuped with --prefer-lowest-stable |
Hm I see, but shouldn't we find another solution to that then than remove the dependency on phpunit which we kind of need to test locally? |
So, spending one more hour on this, I still don't see any use case for specifying "prefer-lowest" but not "prefer-stable" together. In fact, and because I fail to imagine a use case, I fear people will start using "prefer-lowest XOR prefer-stable", and you'll get issues and increase support on your side. Still, I added a commit that splits --prefer-lowest and --prefer-stable so everybody is happy :) Really, after spending time on it, I see a flaw in your reasoning @naderman that may explain our respective pov: when someone sets Did you checkout my branch and run it against e.g. composer and/or symfony? If not, then you really should. That's the experimental argument that made me understand and have my current way of thinking. I'd be happy to remove this last commit if you come to the same conclusion as mine. Or you can merge as is now if you prefer. |
a896606
to
98b254a
Compare
@nicolas-grekas could you give an example of a package where it didn't do the right thing for you? Because even with |
Of course: any Symfony component with dependencies.
|
Yes that makes sense, you use the first beta available as that is what a ~2.4 requirement specifies (any 2.4..). It may not be what everyone wants but strictly speaking that's what prefer-lowest should do IMO. If you use it you get what you ask for. But it probably makes sense to combine with --prefer-stable to most people :) |
Cool, then we can merge as is? |
@@ -700,10 +703,11 @@ private function createPolicy() | |||
// old lock file without prefer stable will return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding prefer-lowest support for the lock file? I understand it's probably not a common use case or none at all but for completeness and to avoid bad surprises it should be persisted to the lock. See a few lines above..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, not sure to understand... Can you drive me a bit more please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, basically the same as https://github.com/composer/composer/pull/3101/files + nicolas-grekas@4bd748b which fixed some mistakes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except preferLowest isn't on the root $package so you'll have to pass it in to the locker directly I guess.
Yes except for the lock support sorry I missed that last time :) |
If my bundle claims to work with 2.4.0-alpha1 or later, by using |
@dbu I agree on principle but in effect nobody is likely to use your bundle with 2.4.0-alpha1 once a 2.4.0 stable is out, but ~2.4 will allow the alpha still, unless you do ~2.4-stable. Under normal conditions composer will take the stable if it's there anyway so I would say for "compat testing" --prefer-stable --prefer-lowest sounds reasonable (you'll catch problems but not waste time debugging issues occuring only with alpha/beta versions of your deps). |
okay. did not want to argue against the combination of --prefer-stable and --prefer-lowest, only that --prefer-lowest alone should install an alpha or beta. |
Ah ok yes for sure :) |
prefer-lowest is now persisted in composer.lock |
Can you be sure to update |
f4fe6a7
to
7c2cade
Compare
CLI doc updated (but there is no schema change for composer.json) |
7c2cade
to
e9d2335
Compare
e9d2335
to
e821ac2
Compare
Great, looks very complete now, thanks @nicolas-grekas! |
add --prefer-lowest and --prefer-stable to update command
…s-grekas) This PR was squashed before being merged into the 2.3 branch (closes #12542). Discussion ---------- Test components using their lowest possible deps | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Once composer/composer#3450 is merged, we'll see if our deps are correct, and ensure that is kept over time by testing each component with its lowest possible deps. Commits ------- 25fef27 Test components using their lowest possible deps
Run
composer update --prefer-lowest-stable
and get all the deps installed to their lowest (pretended) supported versionFixes #3440
Fixes #1902