Closed navigatrum closed 1 year ago
Hi!
I recommend that you use WPCS using Composer per project.
Installing it globally could cause conflicts if you are using Composer in your projects, and dependencies clash.
In your project just do composer require wp-coding-standards/wpcs --dev
, and add the composer plugin so that WPCS standards are visible to PHPCS: composer require --dev dealerdirect/phpcodesniffer-composer-installer
.
Then you can just run vendor/bin/phpcs .
to check your code.
I get the same problem on a global install in macOS Monterey.
Problem 1
- Root composer.json requires dealerdirect/phpcodesniffer-composer-installer ^0.5 || ^0.6 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.5.0, v0.6.0, v0.6.1, v0.6.2].
- dealerdirect/phpcodesniffer-composer-installer[v0.5.0, ..., v0.6.2] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.2.0] but it does not match the constraint.
Problem 2
- phpcsstandards/phpcsdevtools[1.0.1, ..., 1.1.1] require dealerdirect/phpcodesniffer-composer-installer ^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.5.0, v0.6.2].
- phpcsstandards/phpcsdevtools 1.0.0 requires dealerdirect/phpcodesniffer-composer-installer ^0.3 || ^0.4.1 || ^0.5 || ^0.6.2 -> satisfiable by dealerdirect/phpcodesniffer-composer-installer[v0.5.0, v0.6.2].
- dealerdirect/phpcodesniffer-composer-installer[v0.5.0, ..., v0.6.2] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.2.0] but it does not match the constraint.
- Root composer.json requires phpcsstandards/phpcsdevtools ^1.0 -> satisfiable by phpcsstandards/phpcsdevtools[1.0.0, 1.0.1, 1.1.0, 1.1.1].
Based on this error, it looks like the installer is incompatible with Composer 2. I tried upgrading to the latest Composer with composer self-update --2
, but still got the error.
I was able to downgrade Composer to 1 using composer self-update --1
as suggested here. Then the installation completes, although I get the warning
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
If you're installing globally, one way around this is to downgrade Composer, do the install, and then restore Composer to the latest version.
@andfinally See @dingo-d's answer just above your post. You can use the same instructions with global
in them to install globally.
The installer is perfectly compatible with Composer 2.x, but not when using the old 0.6.x
version which was released before Composer 2.x existed..
Closing as duplicate of #1901.
Bug Description
Installing fails with
composer create-project wp-coding-standards/wpcs
. And would seem to work, but throws Fatal Error with standalone installatation.System: Ubuntu 20.04.4 LTS php: 7.4 composer: 2.3.7
First attempt: install locally
command:
Result:
Second attempt: install standalone
Do stuff to do. PHP_CodeSniffer version 2.2.0 (stable) Command:
Result: some very nice:
and cute:
and finally: