PHPCSStandards / composer-installer

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

Do not exit with code 1 on uninstall (--no-dev) #103

Closed tobiasbaehr closed 4 years ago

tobiasbaehr commented 4 years ago

Problem/Motivation

When dealerdirect/phpcodesniffer-composer-installer + package which has phpcs rules are uninstalled while composer install --no-dev the dealerdirect/phpcodesniffer-composer-installer exit with the exitcode 1, which breaks a CI.

Expected behaviour

Do nothing in this case.

Actual behaviour

$ composer install --no-interaction --optimize-autoloader --ansi --no-progress --no-dev
00:03
 No patches supplied.
 Loading composer repositories with package information
 Installing dependencies from lock file
 Package operations: 0 installs, 0 updates, 5 removals
   - Removing squizlabs/php_codesniffer (3.5.3)
 Deleting /builds/foobar/vendor/squizlabs/php_codesniffer - deleted
   - Removing drupal/stage_file_proxy (1.0.0-rc2)
 Deleting web/modules/contrib/stage_file_proxy - deleted
   - Removing drupal/devel (2.1.0)
 Deleting web/modules/contrib/devel - deleted
   - Removing drupal/coder (8.3.7)
   - Removing dealerdirect/phpcodesniffer-composer-installer (v0.6.0)
 Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
 Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
 Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
 Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
 Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
 Generating optimized autoload files
 ERROR: Job failed: exit code 1

Steps to reproduce

Run composer install --no-interaction --optimize-autoloader --ansi --no-progress --no-dev -vv;echo $? to remove the dev-deps and the see the exit code.

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

Environment

Question Answer
OS Mac
PHP version 7.3.13
Composer version 1.9.2
PHP_CodeSniffer version 3.5.3
Dealerdirect PHPCS plugin version v0.6.0
Install type Composer project local

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

ing config file: /.../vendor/squizlabs/php_codesniffer/CodeSniffer.conf

installed_paths: ../../drupal/coder/coder_sniffer

Tested against master branch?

jrfnl commented 4 years ago

@tobiasbaehr Thanks for the detailed report. I'm at a conference right now, but either @Potherca or me will look at this soon.

The main thing which surprises me is that Composer would try to run a plugin which it has just uninstalled. In that respect, I wonder if this is not a Composer bug instead of a bug in the plugin.

The other thing which surprised me when you originally reported it, is that PHPCS would be reported as unavailable as it is a require-ment of this plugin, so if the plugin is installed, PHPCS should always be available.

Anyway, need to get back to the conference now. I will try to have a look at this later tonight or at some point tomorrow.

Potherca commented 4 years ago

I've created automated reproduction scenarios for this bug (in BASH).

Tomorrow I'll work on a fix.

Potherca commented 4 years ago

I've implemented a fix in MR #104. As soon as it has been reviewed and approved I can deploy a new release to get this fix out the door so @tobiasbaehr can verify it resolves things on his end.

tobiasbaehr commented 4 years ago

I can confirm that #104 works for me.

composer install --no-interaction --optimize-autoloader --ansi --no-progress --no-dev -vv;echo $?
Required tags were not explicitly set so the zaporylie/composer-drupal-optimizations set default based on project's composer.json content.
extra.commerce-drupal-optimizations.require.symfony/symfony: '>3.4'
No patches supplied.
Loading composer repositories with package information
Installing dependencies from lock file
Dependency resolution completed in 0.003 seconds
Analyzed 362 packages to resolve dependencies
Analyzed 1174 rules to resolve dependencies
Package operations: 0 installs, 0 updates, 5 removals
Removals: squizlabs/php_codesniffer, drupal/stage_file_proxy, drupal/devel, drupal/coder, dealerdirect/phpcodesniffer-composer-installer
  - Removing squizlabs/php_codesniffer (3.5.3)
Deleting /.../vendor/squizlabs/php_codesniffer - deleted
  - Removing drupal/stage_file_proxy (1.0.0-rc2)
Deleting web/modules/contrib/stage_file_proxy - deleted
  - Removing drupal/devel (2.1.0)
Deleting web/modules/contrib/devel - deleted
  - Removing drupal/coder (8.3.7)
  - Removing dealerdirect/phpcodesniffer-composer-installer (dev-master 2a57571)
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Generating optimized autoload files
Running PHPCodeSniffer Composer Installer
PHPCodeSniffer Composer Installer is uninstalled
0
jrfnl commented 4 years ago

Thanks for testing @tobiasbaehr !

Potherca commented 4 years ago

@tobiasbaehr The fix for this issue has been release as part of v0.6.1. Feel free to update your project(s) as needed.

And thanks again for reporting the issue and testing the fix!