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 does not work when run from WSL drives #3388

Closed
gwharton opened this issue Jul 15, 2021 · 3 comments · Fixed by #3428
Closed

phpcs does not work when run from WSL drives #3388

gwharton opened this issue Jul 15, 2021 · 3 comments · Fixed by #3428

Comments

@gwharton
Copy link

gwharton commented Jul 15, 2021

Describe the bug
When the project (including phpcs vendor folder) is run from a windows network drive (either mapped to drive, or by Path) phpcs cannot be run as it believes the config is not readable.

Code sample
N/A

Custom ruleset
N/A

To reproduce
Steps to reproduce the behavior:

  1. Create project on mapped network drive
  2. Run phpcs --version
  3. See error message displayed
ERROR: Config file \\WSL$\UBUNTU\home\ubuntu\www\vendor\squizlabs\php_codesniffer\CodeSniffer.conf is not readable
ERROR: Config file U:\home\ubuntu\www\vendor\squizlabs\php_codesniffer\CodeSniffer.conf is not readable

Expected behavior
It should work

Versions (please complete the following information):

  • OS: Windows 10 with WSL
  • PHP: 7.4.21
  • PHPCS: 3.6.0
  • Standard: N/A

Additional context
It is the same issue with php's is_readable function that was worked round with this fix. d56e167

is_readable is called here.

PHP_CodeSniffer/src/Config.php

Lines 1659 to 1662 in b6d6556

if (is_readable($configFile) === false) {
$error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
throw new DeepExitException($error, 3);
}

is_readable should be changed to Util\Common::isReadable as per previous fix

@gwharton
Copy link
Author

FIX

--- ./src/Config.orig.php	2021-07-15 10:47:29.220000000 +0100
+++ ./src/Config.php	2021-07-15 10:45:27.980000000 +0100
@@ -1656,7 +1656,7 @@
             return [];
         }

-        if (is_readable($configFile) === false) {
+        if (Util\Common::isReadable($configFile) === false) {
             $error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
             throw new DeepExitException($error, 3);
         }

@jrfnl
Copy link
Contributor

jrfnl commented Sep 6, 2021

@gwharton I've created PR #3428 to address this. Testing appreciated.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Sep 29, 2021
@gsherwood gsherwood added this to the 3.6.2 milestone Sep 29, 2021
gsherwood added a commit that referenced this issue Nov 1, 2021
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Nov 1, 2021
@gsherwood
Copy link
Member

gsherwood commented Nov 1, 2021

Thanks for this bug report and for posting one of the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging a pull request may close this issue.

3 participants