Skip to content
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

Unable to install #2068

Closed
navigatrum opened this issue Jun 24, 2022 · 4 comments
Closed

Unable to install #2068

navigatrum opened this issue Jun 24, 2022 · 4 comments

Comments

@navigatrum
Copy link

navigatrum commented Jun 24, 2022

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:

composer create-project wp-coding-standards/wpcs --no-dev

Result:

Creating a "wp-coding-standards/wpcs" project at "./wpcs"
Info from https://repo.packagist.org: #StandWithUkraine
Installing wp-coding-standards/wpcs (2.3.0)
  - Downloading wp-coding-standards/wpcs (2.3.0)
  - Installing wp-coding-standards/wpcs (2.3.0): Extracting archive
Created project in /home/me/test/wpcs
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.


  Problem 1
    - dealerdirect/phpcodesniffer-composer-installer[v0.5.0, ..., v0.6.2] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.3.0] but it does not match the constraint.
    - 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].

Second attempt: install standalone

Do stuff to do.
PHP_CodeSniffer version 2.2.0 (stable)
Command:

 /home/me/.config/composer/vendor/bin/phpcs --report=json --encoding=UTF-8 --standard=/home/me/test/wpcs/WordPress/ruleset.xml --error-severity=5 --warning-severity=5

Result:
some very nice:

PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1923
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1928
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1928
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1974
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1974

and cute:

PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php on line 1763
PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php on line 2723

and finally:

PHP Fatal error:  Uncaught PHP_CodeSniffer_Exception: Referenced sniff "Generic.Arrays.DisallowShortArraySyntax" does not exist in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1086
Stack trace:
#0 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference()
#1 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1099): PHP_CodeSniffer->processRuleset()
#2 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference()
#3 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1099): PHP_CodeSniffer->processRuleset()
#4 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference()
#5 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(551): PHP_CodeSniffer->processRuleset()
#6 /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php in /home/me/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php on line 1086
@dingo-d
Copy link
Member

dingo-d commented Jun 27, 2022

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.

@andfinally
Copy link

andfinally commented Jul 24, 2022

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.

@jrfnl
Copy link
Member

jrfnl commented Jul 24, 2022

@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..

@jrfnl
Copy link
Member

jrfnl commented Nov 23, 2022

Closing as duplicate of #1901.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants