Closed kevinwhoffman closed 6 years ago
Please try to add the full path to phpcbf
and see if it helps
or add your vendor bin to your path: PATH="./vendor/bin:$PATH"
If you ad to your path, you should be able to use the default setting "phpcbf.executablePath": "phpcbf",
I've tested, and can confirm that adding the full path to phpcbf works find.
I will update the extension later today with support for relative path ie relative to project root
When you install in workspace root, use: phpcbf.executablePath": "${workspaceRoot}/vendor/bin/phpcbf"
${workspaceRoot}
is deprecated. ${workspaceFolder}
is the new multi-root friendly version, which prompts the question of how this extension should be configured in a multi-root project.
The fallback in multi-root for the workspaceRoot variable appears to simply be the first folder in the multi-root settings, meaning, if the correct folder isn't listed in the 0 index of the folders array, it'll fail.
I'm not really suggesting a change, just making a note for future bug reporters.
I'm not familiar enough with the new multi-root relevant apis, but I am pretty sure that there is a declaration of some sort to define a setting as being globally related (folder/file independent) or resource dependent (dealing with files and folders), which is the default this extension is using, is the globally related one (meaning that in mult-root projects, the .vscode/settings.json
in each folder is ignored).
Thank you. It's my first extension so I misunderstood the use of ${workspaceRoot}
(didn't know of ${workspaceFolder}
) . I'll read me up on its use and update the extension.
In a multi-root environment, and only if you use a relative path starting with ${workspaceRoot}
or ./
, I'll iterate through the root folders looking for the file you added https://github.com/soderlind/vscode-phpcbf/blob/master/extension.js#L164-L193
Yeah, it's very new, and (to me at least) pretty confusing. There are User Settings
, but also Workspace Settings
and Folder Settings
now. I think when you register the settings, you have to choose between
Workspace
(a PROJECT.code-workspace
file, which is "scope": "window"
the new default when registering/contibuting your settings) and Folder
( .vscode/settings.json
files, which in multi-root is "scope": "resource"
). So perhaps you should register the settings twice, for both types. (EDIT: Nevermind this. When registering a scope resource, it lets you set it in both places...)
I think that the extension should check for Folder
based options ( "scope": "resource"
), in case phpcs
is composer installed in each folder, and also because each $workspaceFolder might want a different phpcbf.standard
(and phpcbf.enable
, phpcbf.onsave
etc).
I think it might make sense to also register a Workspace File
project-wide setting, to fallback to when the Folder
settings aren't set (some people might not need per-folder settings).
Of course, if you do this, the most important thing would be making the documentation clear ;-). To be honest, none of the plugins I use have gotten this correct yet, and you'd be the first!
i'm still having this issue on windows. i'm using the global phpcbf - which is in the PATH env variable. running phpcbf
directly from cmd works. i tried adding the absolute path (in windows style with \\
) and only the command phpcbf
- always giving me the above error message. has this something to do with how paths are handled?
for anyone coming here: what solved my issue was changing the executablePath in the user-/workspace-config to "phpcbf.bat" on windows. "phpcbf" (without .bat) works in cmd, but not in child_process.spawn (don't know why).
what i also noticed: the default on windows (extension.js
#26) is php-cbf.bat
- the dash should be removed. but the default setting was never called for me - even after removing the executablepath in the user- & workspace settings. maybe this should be filed as a seperate issue? though i had no time to test this in other environments.
Hi, i still have this issue on Windows 10: extension is not working, while running the executable from cmd it works perfectly.
I can call just the executable name, i.e. phpcbf
/phpcbf.bat
(it works with both) without the entire path to the file.
Moreover, if i change my executablePath
from phpcbf
to phpcbf.bat
i get no errors but neither my code is fixed; enabling debug with phpcbf.debug: true
show the output of the .bat
executable that is run on the temporary file but not applied then on the original project file.
Current Behavior
On save, I see the following error:
Error: PHPCBF: spawn ./vendor/bin/phpcbf ENOENT. executablePath not found.
Expected Behavior
Code is beautified on save.
Project Details
VS Code Preferences
Directory Structure
composer.json
Do you see anything that would cause that error?