PHPCSStandards / composer-installer

Composer installer for PHP_CodeSniffer coding standards
https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
MIT License
559 stars 36 forks source link

Plugin is [NOT] incompatible with Composer 2 #119

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

Problem/Motivation

When I try using my projects that have this plugin with Composer v2, I get the following errors:

$ composer update
The "dealerdirect/phpcodesniffer-composer-installer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires dealerdirect/phpcodesniffer-composer-installer ^0.6.2 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.6.2].
    - dealerdirect/phpcodesniffer-composer-installer v0.6.2 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

Expected behaviour

This plugin should work with Composer 2.

Actual behaviour

See error message above.

Steps to reproduce

Upgrade to Composer 2 (composer self-update --2).

Proposed changes

N/A

Environment

Question Answer
OS Mac (Mojave)
PHP version 7.3.x
Composer version 2.x
PHP_CodeSniffer version latest
Dealerdirect PHPCS plugin version latest
Install type Composer project local

Output of vendor/bin/phpcs --config-show:

$ vendor/bin/phpcs --config-show
Using config file: /Users/jgeerling/Sites/jeffgeerling-com/vendor/squizlabs/php_codesniffer/CodeSniffer.conf

installed_paths: ../../drupal/coder/coder_sniffer,../../sirbrillig/phpcs-variable-analysis

Tested against master branch?

jrfnl commented 4 years ago

Composer treats minors below 1.0 as majors, so you need to explicitly upgrade your version constraints to allow for version 0.7.x of this plugin.

Version 0.7.0 was released last June and is fully ready for Composer 2.0, while also still supporting Composer 1.0. https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.7.0

So: composer require --dev dealerdirect/phpcodesniffer-composer-installer:"^0.7.0" and your problem should be fixed.

geerlingguy commented 4 years ago

Ah... you're quite correct. I'm trying to sift through a number of new Composer v2-related build issues across many projects I maintain that popped up over the weekend, and I didn't notice that my version of this plugin was actually behind.

I required the latest version and now it seems everything is working with v2 correctly. Thanks for the quick help!

joelpittet commented 4 years ago

I changed the version manually in the global composer.json file, and removed hirak/prestissimo to unblock myself here. thanks @geerlingguy for digging in and @jrfnl for the fix!

lilithebowman commented 3 years ago
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - dealerdirect/phpcodesniffer-composer-installer v0.6.2 requires php ^5.3|^7 -> your PHP version (8.0.0) does not satisfy that requirement.
    - dealerdirect/phpcodesniffer-composer-installer v0.6.1 requires php ^5.3|^7 -> your PHP version (8.0.0) does not satisfy that requirement.
    - dealerdirect/phpcodesniffer-composer-installer v0.6.0 requires php ^5.3|^7 -> your PHP version (8.0.0) does not satisfy that requirement.
    - dealerdirect/phpcodesniffer-composer-installer v0.5.0 requires php ^5.3|^7 -> your PHP version (8.0.0) does not satisfy that requirement.

How is this invalid?

This suddenly broke a CI for me. 🤷‍♀️

jrfnl commented 3 years ago

@lilithebowman Your issue is a different one from the one described above.

All the same, the solution is the same: update the allowed version of this plugin to ^0.7.0.

Background: Any version of the plugin prior to 0.7.0 only allowed installation on PHP 5.x and 7.x. Version 0.6.2 (the last version before 0.7.0) was released in January this year, well before it was clear what would change in PHP 8, so there was no way it could be guaranteed that the plugin would work on PHP 8.x.

Once the first alpha release for PHP 8.0 came out, the plugin was tested on PHP 8.0 and the PHP version constraints widened to allow installation on PHP 8.0. This change was included in the 0.7.0 release.

And as Composer treats minors below 1.0 as majors, you need to explicitly update your version constraints to allow for version 0.7.x of this plugin.

Potherca commented 3 years ago

I've created a new issue based on @lilithebowman's comment to address this issue if/when it occurs for other users.