-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[with patch] requiring a platform package that is provided by another required package fails #5030
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
Comments
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" ;) |
I think the patch is fine and might as well be a PR. |
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 |
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 ;) |
@dzuelke would you mind opening a PR on the packagist repo to provide a fix ? |
Except that these features are actually related. The way the repository protocol works is that the provider file for |
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 |
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 |
@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 |
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. |
Yeah I never suggested we fix it with that patch for 2.0. There's a
bigger refactoring planned that would fix this.
|
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. |
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 |
It's an issue for me, since I have to run around telling people that they need to add |
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. |
Any progress on this? 😢 |
This seems to be caused at least partially by #6753 |
With such a clear and comprehensive write-up, and a patch to boot, this shouldn't be left hanging so long... |
Well. It's tough to fix since it's a conceptual deficiency. However, @Seldaek promised they'd fix it for Composer v2 ;) |
I'll be dead before then. |
is any update for this ? im having this error, just followed every instruction i found but nothing seems to work and the "alcaeus/mongo-php-adapter": "dev-composer-provide", is no longer available roblem 1 |
Please read the installation instructions for the package in question and you'll see that this has been solved in a better way. |
This should work in 2.0 so closing |
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
The text was updated successfully, but these errors were encountered: