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

Single File Error #123

Open
jacobcassidy opened this issue May 11, 2024 · 7 comments
Open

Single File Error #123

jacobcassidy opened this issue May 11, 2024 · 7 comments

Comments

@jacobcassidy
Copy link

When opening a single PHP file in VSCode, running the PHPCBF: Fix this file command results in the following error: command 'fixer.fix' not found. The linter (phpcs) also does not work on single files. The following is logged in the output panel:

2024-05-11 21:09:27.667 [error] [valeryanm.vscode-phpsab] provider FAILED
2024-05-11 21:09:27.667 [error] undefined

All works as intended when adding a folder with the file in it to VSCode.

Is this the intended behavior, or is there a bug when not using project folders?

@valeryan
Copy link
Owner

Hey @jacobcassidy. I think it should work so I would call it a bug. I will have to look at the behavior but off the top of my head the reason will probably be that the vscode api that is used by the extension is only looking for workspace. More than likely with a single file the workspace is not present, breaking the extension. We will have to look at the behavior and see if that can be addressed.

@jonathanbossenger
Copy link
Collaborator

I was able to replicate this by selecting a single file in my file explorer, opening it with VS Code, and running the PHPCBF: Fix this file command.

I'll run this through the development version of the extension later today, and report back any findings.

@michael-sumner
Copy link

@jonathanbossenger has there been any findings on this one? I too am receiving the same error recently.

@Nalci
Copy link

Nalci commented Jul 22, 2024

Installed today this extension in VSC and get the same error

@valeryan
Copy link
Owner

Yes, this is a confirmed error. The extension uses VSCode's workspace API to access files and relies heavily on files in directory to work and none of that is available when VSCode is in single file mode. The extension requires composer and xml configuration files, and directory access, etc. at minimum it can handle this error gracefully and inform better why it doesn't work. If I have time to work on this I might get single file mode working but it will require global compose setup, and a global ruleset, etc.

@jonathanbossenger
Copy link
Collaborator

@valeryan For now, maybe if we just add a note in the readme that this only works when opening PHP files in a directory?

@sephentos
Copy link

sephentos commented Nov 26, 2024

@valeryan I am also getting this error, even when running inside a workspace.

Linting works, formatting does not work.

image

image

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

6 participants