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
composer require doesn't respect prefer-stable #4318
Comments
|
Can you provide an example of a package (and the version string you set) that downloads as dev instead of stable? |
|
It does that with any package, not one in particular. Fairly easy to reproduce: $ composer --version
Composer version 1.0-dev (a67eaf04c7eee3d10d7c64f3eef47995ec150ffe) 2015-07-30 12:14:55
$ echo '{}' > composer.json
$ composer require madewithlove/elasticsearcher
Using version ^0.2.2 for madewithlove/elasticsearcher
./composer.json has been updated
$ echo '{"minimum-stability": "stable", "prefer-stable": true}' > composer.json
$ composer require madewithlove/elasticsearcher
Using version ^0.2.2 for madewithlove/elasticsearcher
./composer.json has been updated
$ echo '{}' > composer.json
$ echo '{"minimum-stability": "dev", "prefer-stable": true}' > composer.json
$ composer require madewithlove/elasticsearcher
Using version ^0.2.0@dev for madewithlove/elasticsearcher
./composer.json has been updated |
|
What you see there are the generated version constraints for the require, the actually installed packages based on those constraints should be exactly what you expect. Please check which versions you actually got installed. I suspect this works exactly as it should. |
|
Nope it really requires the dev version: $ echo '{"minimum-stability": "dev", "prefer-stable": true}' > composer.json
$ composer require phpunit/phpunit
Using version ^5.0@dev for phpunit/phpunit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
[...]
- Installing phpunit/phpunit (dev-master e78d394)
Cloning e78d39417dd724f4789ec0518e5b1c6d85293e6e
Writing lock file
Generating autoload files
$ cat composer.json
{"minimum-stability": "dev", "prefer-stable": true,
"require": {
"phpunit/phpunit": "^5.0@dev"
}
}
$ phpunit --version
PHPUnit 5.0-ge78d394 by Sebastian Bergmann and contributors. |
|
That is because there is no stable 5.x release yet of phpunit.
|
|
I think the require command creates a constraint based on the very latest
|
|
As I said it might just be me not getting how it should work, the docs says:
So to me, as I didn't say I wanted phpunit 5.x, prefer stable should require 4.7.7. My use case is that I want all my packages to be stable, but in this case I need |
|
Then you should really just include that one particular package for now using: Now to elaborate again (based on your phpunit example); when you use the The prefer-stable flag only comes into play once it starts trying to resolve this new requirement, which is the next step in the process. However, for the version it found in the previous step, there is no stable release yet, so it will go with the dev version (until a stable release is made). Does that make sense? |
|
@alcohol I think that explains the current process very well, but still when picking the preferred version to build the constraint from we should ideally take into account prefer-stable and not take the absolute highest value. I'd argue we should probably assume prefer-stable true no matter what actually, because it's never really a good thing to install an unstable version unless people willingly ask for it, or there is no stable version at all to pick from. And ideally we should also make sure it doesn't require a version that can't be installed at all with the current constraints, but that might be difficult to check for, not sure. |
I think that would make more sense indeed, I rarely ever want an unstable package, and when I do it's because I know I need a bugfix or something and said package doesn't have any branch alias, so I know what constraint I want anyway. |
|
Dang. 507415e made it so that I cant set prefer-stable to false and have it grab the latest dev without having to specify it. |
|
@ryanaslett this could be remedied by having the require and init command pass the current known prefer-stable config value to |
|
My use case is such a bizzare edge case that Im almost embarrassed to even describe it. I'll open a new issue and see if it makes sense to do what you suggest, or if there might be an alternative. |
Maybe it's just me not getting how it should work but granted the following configuration:
{ "minimum-stability": "dev", "prefer-stable": true }I'd expect
composer requireto pick stable packages, instead I get@devversions, is this expected behavior?The text was updated successfully, but these errors were encountered: