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

phpcs: Exit Code: 127 (Command not found) on every Composer command #48

Closed
kenorb opened this issue Mar 23, 2018 · 3 comments
Closed

phpcs: Exit Code: 127 (Command not found) on every Composer command #48

kenorb opened this issue Mar 23, 2018 · 3 comments

Comments

@kenorb
Copy link

kenorb commented Mar 23, 2018

Problem/Motivation

After installed "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", my Composer getting error about phpcs command not being found.

This happens, when I am working with multiple bin-dir folders. Normally I've got COMPOSER_BIN_DIR pointed to /usr/local/bin, but in some shell instances, I don't have. After installing this package, now every composer is producing the error.

Expected behaviour

The processing should be ignored when the binary can't be found.

Actual behaviour

$ composer global show
Changed current directory to /Users/kenorb/.composer

                                                                                                      
  [Symfony\Component\Process\Exception\ProcessFailedException]                                        
  The command "'/Users/kenorb/.composer/vendor/bin/phpcs' '--config-show' 'installed_paths'" failed.  
                                                                                                      
  Exit Code: 127(Command not found)                                                                   
                                                                                                      
  Working directory: /Users/kenorb/.composer                                                          
                                                                                                      
  Output:                                                                                             
  ================                                                                                    
                                                                                                      
                                                                                                      
  Error Output:                                                                                       
  ================                                                                                    
  sh: /Users/kenorb/.composer/vendor/bin/phpcs: No such file or directory                             
                                                                                                      

global <command-name> [<args>]...

Exception trace:
 () at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/vendor/symfony/process/Process.php:221
 Symfony\Component\Process\Process->mustRun() at /Users/kenorb/.composer/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php:183
 Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin->loadInstalledPaths() at /Users/kenorb/.composer/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php:121
 Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin->init() at /Users/kenorb/.composer/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php:103
 Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer\Plugin->activate() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Plugin/PluginManager.php:236
 Composer\Plugin\PluginManager->addPlugin() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Plugin/PluginManager.php:205
 Composer\Plugin\PluginManager->registerPackage() at phar:///usr/local/Cellar/composer/1.6.3/libexec/composer.phar/src/Composer/Plugin/PluginManager.php:261
...

Steps to reproduce

COMPOSER_BIN_DIR="/usr/local/bin" composer global require dealerdirect/phpcodesniffer-composer-installer:^0.4.3
composer -v global show

Proposed changes

The plugin should be less invasive.

@Potherca
Copy link
Member

Hi! Thank you for taking the time to report this.

This behaviour seems to be caused by the fact that the plugin functionality is called when it should not be. In other words, the plugin is triggered for an event it is not registered for.

The root cause is that the (public) activate function calls the (private) init function which, in turn, triggered calling PHPCS (in the loadInstalledPaths function).

A potential solution would be simply move the init call into the onDependenciesChangedEvent function.

That way init is only called when the plugin is about to be used, rather than on any composer command.

@jrfnl
Copy link
Member

jrfnl commented Sep 7, 2018

Looks like PR #51 addresses this issue.

@frenck
Copy link
Contributor

frenck commented Oct 25, 2018

This is indeed addressed by #51, which has been merged in and will be part of the next release.

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