Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[with patch] requiring a platform package that is provided by another required package fails #5030
Comments
Seldaek
added
the
Bug
label
Mar 9, 2016
Seldaek
added this to the Bugs milestone
Mar 9, 2016
This comment has been minimized.
This comment has been minimized.
It's important to understand that in the case of a file like However, as (maybe an unintentional?) a side effect, this allows dependencies on packages provided by others. Check out At least that's how I understand it. @Seldaek just told me "yeah this might all be accidental" ;) |
This comment has been minimized.
This comment has been minimized.
I think the patch is fine and might as well be a PR. |
Mar 26, 2016
This was referenced
Seldaek
modified the milestones:
1.1,
Bugs
Apr 11, 2016
This comment has been minimized.
This comment has been minimized.
The fact that this file contains all packages providing it is necessary. Otherwise, composer would not be able to look for I think the right fix would be for Packagist to dump such files for any package referenced in |
This comment has been minimized.
This comment has been minimized.
Yeah I agree that this should be fixed on the Packagist side (I pointed that out at the end of my original report). My second comment was just to point out that the "provider-…" files are not specifically for the "provide" feature, but for the "providers" functionality of Packagist type repos. In case anyone confused the two ;) |
Seldaek
modified the milestones:
1.1,
1.2
Apr 28, 2016
This comment has been minimized.
This comment has been minimized.
@dzuelke would you mind opening a PR on the packagist repo to provide a fix ? |
stof
referenced this issue
May 10, 2016
Closed
Add proper provides rules for mbstring and iconv polyfills #54
This comment has been minimized.
This comment has been minimized.
Except that these features are actually related. The way the repository protocol works is that the provider file for |
This comment has been minimized.
This comment has been minimized.
The term "provides" in a Composer type repository refers to "packages provided by that repo", not "packages provided by other packages", @stof. It just happens that this feature is used for the |
This comment has been minimized.
This comment has been minimized.
I just don't think we should fix this at the packagist level right now, because it'll create even more legacy to remove later on. We want to clean this up in 2.0 and fix the providers handling so that the files on packagist do not have to include all providers (which would shrink some of them quite substantially). /cc @naderman |
This comment has been minimized.
This comment has been minimized.
@Seldaek but then, how would composer know which files it should load to find And as I said, fixing the issue on Packagist is just a matter of updating the regex above so that it does not exclude package names like |
This comment has been minimized.
This comment has been minimized.
Composer does not and can not know which package to load for psr/log-implementation.. You should require an implementation, and that implementation providing psr/log-implementatoin should be enough for Composer to figure things out. Right now that last part fails if we remove the providers on packagist, but that's what we want to fix. The ext-mbstring issue in practice isn't an actual problem right now except for @dzuelke but AFAIK he solved it, so let's please not waste time discussing this and create more legacy for something that will be removed anyway. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah I never suggested we fix it with that patch for 2.0. There's a
bigger refactoring planned that would fix this.
|
This comment has been minimized.
This comment has been minimized.
OK, so which fix should we use for Composer 1.x ? 2.0 is not yet a thing, and this issue affects any package providing a polyfill for an extension. So this affects the ext-mongo polyfill mentioned by @dzuelke above (which is not solved as the only way to fix it he found was to register the package repository explicitly rather relying on packagist, which is not something easy for people affected by this issue) but would also affect the symfony polyfill once they tell composer that they are polyfill (see symfony/polyfill#54) instead of forcing any library to stop requiring ext-mbstring explicitly when they want to be compatible with these polyfills. |
This comment has been minimized.
This comment has been minimized.
It's also not an issue for me mind you, since deploys to Heroku require a It's an issue for any user of a polyfill like the |
This comment has been minimized.
This comment has been minimized.
alcaeus
commented
May 13, 2016
It's an issue for me, since I have to run around telling people that they need to add |
referenced
this issue
in doctrine/doctrine-website-sphinx
Jun 1, 2016
Seldaek
modified the milestones:
1.2,
1.3
Jul 2, 2016
Seldaek
modified the milestones:
1.4,
1.3
Nov 6, 2016
alcaeus
referenced this issue
Dec 21, 2016
Open
Composer update fails when providing platform package #5987
This comment has been minimized.
This comment has been minimized.
robfrawley
commented
Feb 22, 2017
•
What is the status of this? Trying to use any library that polyfills extension behavior is impossibly difficult and complex to get right. It shouldn't be. Correct me if I am wrong, but it looks like this issue is continually being pushed to the next release...but this should be a "blocker" as it quite literally describes a broken implementation for a feature that is documented involving the most important aspect of Composer: dependency resolution. |
jordisala1991
referenced this issue
Feb 25, 2017
Merged
Add mongodb to PHP7 with ext-mongo compatibility #238
Seldaek
modified the milestones:
1.4,
2.0
Mar 7, 2017
Seldaek
referenced this issue
Mar 7, 2017
Closed
package provide extension not used in resolve dependencies #6177
This comment has been minimized.
This comment has been minimized.
Aeolun
commented
Apr 27, 2017
Any progress on this? |
jordisala1991
referenced this issue
Oct 14, 2017
Closed
Add composer flags to every update command, remove quiet flag #305
This comment has been minimized.
This comment has been minimized.
This seems to be caused at least partially by #6753 |
dzuelke commentedMar 9, 2016
•
edited
First, this issue is not entirely trivial to reproduce, because everyone has different PHP versions and extensions installed. To reproduce the steps and behaviors below, please ensure that you run
php -n $(which composer)
instead of plainlycomposer
, or that withcomposer show --platform | grep mongo
, nothing shows up :)If you're on Ubuntu or something,
php -n
will also prevent loadingext-phar
, so nothing will work. In that case, just make sure you have noext-mongo
, and runcomposer
directly instead ofphp -n $(which composer)
.Let's say your code needs
ext-mongo
(via Doctrine ODM, for instance), but that's not available on PHP 7, so you want to use https://github.com/alcaeus/mongo-php-adapter, which in itscomposer.json
says"provide": { "ext-mongo": "1.6.12" }
, and which is a wrapper aroundext-mongodb
to provide an interface that's compatible with the oldext-mongo
.Start with a basic
composer.json
, to mock the existence ofext-mongodb
(again, you do not wantext-mongo
installed when following along, so always run withphp -n
later):I will use the
composer-provide
branch of https://github.com/alcaeus/mongo-php-adapter explicitly because the master branch has changed between usingprovide
andreplace
a few times recently. There is also acomposer-replace
branch that usesreplace
instead ofprovide
forext-mongo
.Remember,
php -n
will prevent ini loads, so if you have ext-mongo locally, it should not get loaded:Now there is a package that provides "ext-mongo" installed, and that info is in the lock file. Which works as expected if you now require that extension:
A subsequent
composer update
also works. Great, so let's try a case that fails - having the requirements already in place, but no lock file:Weird, right? The same happens if you require both in one go obviously:
You could of course also manually put both packages into
composer.json
and runcomposer update
, same effect (that's actually what happened when we removed lock file and vendor dir earlier and ran an update).For the steps above, instead of requiring
ext-mongo
, you can also usedoctrine/mongodb
, which in turn requiresext-mongo
. Same behavior.There is a workaround: if you put the "alcaeus/mongo-php-adapter" package into a "package" repo inside composer.json, things work. Take this
composer.json
:That works:
This pointed to a problem with information from Packagist, and indeed, it's due to behavior in (and data available to)
ComposerRepository
.There is no information from Packagist on provided platform packages such as
ext-mongo
, so without a lock file, the info that one of the other required packages providesext-mongo
is apparently not there, and that's why things fail.Here is the fix:
However, that feels like a band-aid treating a symptom of the real underlying issue, which is that Packagist does not have a list of provider packages for platform packages:
/cc @alcaeus @holtkamp @stof