composer-normalize: Normalizing `composer.json` in other directory inconsistency
Steps required to reproduce the problem
- Having Composer 2.2 with the new
allow-pluginsfeature - First
composer.json, in the root, perfectly fine:
{
"require": {
"ergebnis/composer-normalize": "^2.23.0",
"phpstan/extension-installer": "^1.1.0"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true
}
}
}
- Second
composer.json, in subdirectoryfoowith a content (clearly, not normalized):
{
"require": {
"psr/log" : "*",
"psr/container" : "*"
}
}
- We run in the root
composer normalize foo/composer.json
Expected Result
composer.jsoninfoois normalized, with no questions asked
Actual Result
Running ergebnis/composer-normalize by Andreas Möller and contributors.
ergebnis/composer-normalize contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "ergebnis/composer-normalize" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] n
phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] n
Successfully normalized subdirectory/composer.json.
Composer asks for plugins to be allowed (phpstan/extension-installer is only to show that it asks for all, not only about the currently used plugin), having using plugin denied it still normalizes composer.json.
I’d expect normalizing composer.json without any interaction, I’d understood not normalizing it after not allowing the plugins, but this behaviour is super weird.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (7 by maintainers)
Commits related to this issue
- For custom composer.json paths the default cwd should be that files directory, fixes ergebnis/composer-normalize#865, refs #10935 — committed to composer/composer by Seldaek 2 years ago
https://github.com/composer/composer/commit/93eb19e756aac57d134cb0350e42cbced2befc57 should resolve this -
composer self-update --snapshotwill let you test it for now.OK I think I see the issue… Probably should use the file’s dir as CWD when loading a Composer instance like that, it’d make more sense. I’ll see if I can fix that on the Composer side.
I can confirm it resolves the problem.
@secretsayan
I‘ll see what I can do about it! Thank you for your report.
Thank you, @secretsayan!
@kubawerlos @secretsayan
Not sure, but seems to me like this is expected behavior.
I will take a closer look.