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

Setting an invalid installed path breaks all commands #1495

Closed
stuporglue opened this issue Jun 2, 2017 · 2 comments
Closed

Setting an invalid installed path breaks all commands #1495

stuporglue opened this issue Jun 2, 2017 · 2 comments
Milestone

Comments

@stuporglue
Copy link

stuporglue commented Jun 2, 2017

I tried to set two installed paths like so:

phpcs --config-set installed_paths ~/projects/wpcs/:/usr/local/etc/php-code-sniffer/Standards

And now everything is coming up:

admin:~$ phpcs  -i
PHP Fatal error:  Uncaught UnexpectedValueException: DirectoryIterator::__construct(/Users/admin/projects/wpcs/:/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory in /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php:84
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php(84): DirectoryIterator->__construct('/Users/admin/pr...')
#1 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php(219): PHP_CodeSniffer\Util\Standards::getInstalledStandards()
#2 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php(432): PHP_CodeSniffer\Config->__set('standards', Array)
#3 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php(323): PHP_CodeSniffer\Config->restoreDefaults()
#4 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Runner.php(64): PHP_CodeSniffer\Config->__construct()
#5 /usr/local/Cellar/php-code-sniffer/3.0.0/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#6 {main}
  thrown in /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php on line 84

Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(/Users/admin/projects/wpcs/:/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory in /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php on line 84

UnexpectedValueException: DirectoryIterator::__construct(/Users/admin/projects/wpcs/:/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory in /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php on line 84

Call Stack:
    0.0016     354664   1. {main}() /usr/local/Cellar/php-code-sniffer/3.0.0/bin/phpcs:0
    0.0110     498144   2. PHP_CodeSniffer\Runner->runPHPCS() /usr/local/Cellar/php-code-sniffer/3.0.0/bin/phpcs:18
    0.0158     738280   3. PHP_CodeSniffer\Config->__construct() /usr/local/Cellar/php-code-sniffer/3.0.0/src/Runner.php:64
    0.0158     738680   4. PHP_CodeSniffer\Config->restoreDefaults() /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php:323
    0.0158     741296   5. PHP_CodeSniffer\Config->__set() /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php:432
    0.0173     766184   6. PHP_CodeSniffer\Util\Standards::getInstalledStandards() /usr/local/Cellar/php-code-sniffer/3.0.0/src/Config.php:219
    0.0197     770848   7. DirectoryIterator->__construct() /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php:84

I can't use --config-delete

admin:~$ phpcs --config-delete installed_paths
PHP Fatal error:  Uncaught UnexpectedValueException: DirectoryIterator::__construct(/Users/admin/projects/wpcs/:/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory in /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php:84
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/3.0.0/src/Util/Standards.php(84): DirectoryIterator->__construct('/Users/admin/pr...')

and I don't know what to do.

I can't find where the config file is located, or I'd just delete it or edit it by hand. How can I fix this?

@stuporglue
Copy link
Author

stuporglue commented Jun 2, 2017

I found that the file name is CodeSniffer.conf and found where it was using Xdebug (/usr/local/Cellar/php-code-sniffer/3.0.0/CodeSniffer.conf, since I installed using Brew).

It would be convenient if instead of crashing, PHPCS would catch the error and maybe indicate which file the bad path came from.

@gsherwood gsherwood changed the title I set an invalid installed_paths and now I can't unset it Setting an invalid installed path breaks all commnads Jun 6, 2017
@gsherwood gsherwood changed the title Setting an invalid installed path breaks all commnads Setting an invalid installed path breaks all commands Jun 6, 2017
@gsherwood
Copy link
Member

I'm glad you found the file and were able to resolve this manually. I've committed a fix so that invalid paths don't break PHPCS any more. Thanks for reporting this.

@gsherwood gsherwood added this to the 3.0.1 milestone Jun 11, 2017
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

2 participants