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

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

Closed
1 task done
tobiasbaehr opened this issue Jan 25, 2020 · 6 comments
Closed
1 task done

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

tobiasbaehr opened this issue Jan 25, 2020 · 6 comments
Assignees

Comments

@tobiasbaehr
Copy link

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?

  • I have verified the issue still exists in the master branch.
@jrfnl
Copy link
Member

jrfnl commented Jan 25, 2020

@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
Copy link
Member

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

Tomorrow I'll work on a fix.

Potherca added a commit to potherca-contrib/phpcodesniffer-composer-installer that referenced this issue Jan 26, 2020
If the phpcodesniffer-composer-installer plugin is installed as a dev
requirement and it is then uninstalled as part of a "--no-dev" install, a bug
occurs. The bug that occurs is that the plugin complains that the  package
"squizlabs/php_codesniffer" is not installed without checking if the package
should be present.

This commit adds a check to verify that this plugin is actually installed before
complaining about the missing package. If this plugin itself is removed, then
it should not complain about the missing package.
@Potherca
Copy link
Member

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.

jrfnl added a commit that referenced this issue Jan 27, 2020
@tobiasbaehr
Copy link
Author

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
Copy link
Member

jrfnl commented Jan 27, 2020

Thanks for testing @tobiasbaehr !

@Potherca
Copy link
Member

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

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

3 participants