junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

php-cs-fixer.executablePath works, but not in combination with ${workspaceFolder} that contains a SPACE #216

Open WybeBosch opened 3 months ago

WybeBosch commented 3 months ago

Context

https://github.com/junstyle/vscode-php-cs-fixer/pull/182 I see this previous ticket resulted in making it so that ${workspaceFolder} can be used, which is great since i have about 100 sites that all have a local version of php-cs-fixer. For those in the config i use

"php-cs-fixer.executablePath": "${workspaceFolder}/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer",

Which equals to

"/Users/name/Local Sites/client/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"

The issue

However the issue is that the file path contains a space in the "Local Sites" directory, and yes its stupid that it contains a space, but its not a directory name i can change since im using "Local by Flywheel" which creates and expects the directory to be that way.

Thus resulting in this error:

runAsync: spawn /Users/name/Local Sites/client/app/public/web/app/themes/sage/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
[
  "fix",
  "--using-cache=no",
  "--format=json",
  "--rules=@PSR12",
  "--path-mode=override",
  "/var/folders/cs/_xsxqrm14d3b3_mw0svyscdh0000gn/T/pcf-tmp0.18446464208639424/functions.php"
]
{
  "cwd": "/Users/name/Local Sites/client/app/public/web/app/themes/sage",
  "shell": true
}
runAsync: error
{
  "exitCode": 126,
  "stdout": null,
  "stderr": "/bin/sh: /Users/name/Local: Permission denied\n"
}
runAsync: reject promise
/bin/sh: /Users/name/Local: Permission denied

As you can see it gets confused by the space in the foldername and aborts early.

Is there any way you can modify the way that executablePath is taken in? Since

I have found this other issue where someone else is having the same issue, and there they modified the internal command the extension uses i believe.

https://github.com/microsoft/vscode/issues/57148

Extra info:

WybeBosch commented 2 months ago

@junstyle Is it possible that 2 days ago you released a new version that no longer supports the path filtering? Since right now its not working anymore, but if i go back a version then it works again.

Version where its having troubles loading the config 0.3.19 Version if i go back where it seems to work 0.3.18

junstyle commented 2 months ago

@WybeBosch path filtering? what's your config? please paste

WybeBosch commented 2 months ago

@junstyle My config is still the exact same as before but i was on the newer update. It was fixed in version 0.3.18, then broke again in version 0.3.19, and now its fixed again in version 0.3.20 :) So this ticket can be closed i think:)









But here is the information you asked for:

===========================================================================

This was the issue about quoting the file paths for the config / executeable Path.

The below information was when i was still on 0.3.19

Phpcsfixer vscode version: 0.3.19 Config: https://pastebin.com/aULc9CGg Using the vscode config settings

"php-cs-fixer.executablePath": "/Users/username/Local Sites/clientname/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer",
"php-cs-fixer.config": "/Users/username/Local Sites/clientname/app/public/.php-cs-fixer.php",

getting the same error where it doesnt like that there is a space in the root path:

runAsync: spawn "/Users/username/Local Sites/clientname/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
[
  "fix",
  "--using-cache=no",
  "--format=json",
  "--config=/Users/username/Local Sites/clientname/app/public/.php-cs-fixer.php",
  "--path-mode=override",
  "/var/folders/cs/_xsxqrm14d3b3_mw0svyscdh0000gn/T/pcf-tmp0.4836255640172413/poet.php"
]
{
  "cwd": "/Users/username/Local Sites/clientname/app/public/web/app/themes/sage/config",
  "shell": true
}
runAsync: error
{
  "exitCode": 16,
  "stdout": null,
  "stderr": "PHP CS Fixer 3.63.1 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.\nPHP runtime: 8.1.29\n\nIn ConfigurationResolver.php line 960:\n                                                                               \n  The config file: \"/Users/username/Local\" does not return a \"PhpCsFixer\\ConfigIn  \n  terface\" instance. Got: \"integer\".                                           \n                                                                               \n\nfix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--sequential] [--] [<path>...]\n\n"
}
runAsync: reject promise
PHP CS Fixer 3.63.1 7th Gear by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.1.29

In ConfigurationResolver.php line 960:

  The config file: "/Users/username/Local" does not return a "PhpCsFixer\ConfigIn  
  terface" instance. Got: "integer".                                           

fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--sequential] [--] [<path>...]