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

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

Open
WybeBosch opened this issue Aug 12, 2024 · 3 comments

Comments

@WybeBosch
Copy link

WybeBosch commented Aug 12, 2024

Context

#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 cannot change the directory name
  • putting quotes around the entire string, makes it so that ${workspaceFolder} is no longer interpreted
  • i have no other ways to modify workspaceFolder so that it escapes the space in the path.

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.

microsoft/vscode#57148

Extra info:

  • macos m1

  • PHP 8.1.29 (cli)

  • Version of php-cs-fixer vscode extension
    0.3.14 - 4 days ago (current)

  • Local version of php-cs-fixer in project "v3.61.1"

  • Path to local php-cs-fixer
    /Users/name/Local Sites/client/app/public/vendor/friendsofphp/php-cs-fixer/php-cs-fixer

  • Path to local php-cs-fixer config file
    /Users/name/Local Sites/client/app/public/.php-cs-fixer.php

  • config file: https://pastebin.com/9dQuesWu

junstyle pushed a commit that referenced this issue Aug 13, 2024
@WybeBosch
Copy link
Author

WybeBosch commented Sep 3, 2024

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

junstyle commented Sep 4, 2024

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

@WybeBosch
Copy link
Author

WybeBosch commented Sep 5, 2024

@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>...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants