simple-php-cs-fixer
simple-php-cs-fixer copied to clipboard
'Unknown Error'
Sorry to be the first person to add an issue :-/ Especially as it's such a vague one...
Installed the plugin but when I run it I just get the vscode error dialog at the top of the page saying 'Simple PHP CS Fixer: Unknown error.' I can run php-cs-fixer fix path/to/the/same/file.php
in the terminal and it works ok. There's nothing being logged in the output/problems/terminal - so I'm not even sure where to start fixing it myself - sorry :-/ If there's anything I can do in vscode to help just let me know and I can stop annoying you ;-)
Ah - discovered the developer tools which shows :
[InvalidArgumentException]
The configuration "/Users/ohffs/Documents/code/project/.php_cs.dist" is not defined.
But the file does exist and if I run php-cs-fixer with the --config-file pointing at it then it works ok. It's quite possible I'm doing something really dim :-)
What happens if you run:
php-cs-fixer fix yourfile.php --config=/Users/ohffs/Documents/code/project/.php_cs.dist
?
That runs fine too I'm afraid.
I tried removing the extension and re-installing it in a new project. On first run I get both the 'Unknown error' and a 'Cannot find .php_cs.dist' one. If I create the dist file then it's back to just the unknown error, but this time in the dev tools I get :
[Symfony\Component\Filesystem\Exception\IOException] Failed to write file ".php_cs.cache", "no reason available".
Not entirely sure it's related, but I see similar errors being reported on the formatter extension here : https://github.com/Dickurt/vscode-php-formatter/issues/15
By any chance, are you on windows? - I just uploaded a fix that makes this extension cross-platform
No - not on Windows I'm afraid. That way lies madness ;-) I'll maybe have a play with it again tomorrow and see if I can get you some more useful info. It's probably just some weird quirk of the way my machines are set up :-) I'm sure you'd have more people pestering you if it was a common issue :-)
K, cool - let me know. I wouldn't be too sure, I imagine it has something to do with the php-cs-fixer
being run in a node chid-process using spawn
, and that may be blocking symfony from writing to the file? I don't know
Let me know what you find - thanks!
Sorry for the delay - I got a colleague at work to try installing the plugin (they'd never had php-cs-fixer installed at all) and hit exactly the same issue on their Mac. Sadly, the debug tools just give the same helpful-not-helpful 'unknown error' message - sorry.
Not at all sure it's related, but when I run it on yet another Mac I get the same unknown error - but also :
[Extension Host]
[ErrorException]
tempnam(): file created in the system's temporary directory
console.ts:123 [Extension Host] fix [--config CONFIG] [--config-file [CONFIG-FILE]] [--dry-run] [--level LEVEL] [--fixers FIXERS] [--diff] [--format FORMAT] [--] [<path>]
Which is possibly related, or possibly not. I can see a ref to a similar thing here about a change in php 7.1 which is what I and my colleagues machines are running.
Anyway - if none of that helps feel free to close the issue :-) If I get time to debug more I will gently prod you ;-)
I've had the same "Unknown Error" pop up repeatedly as well. Debug logs seems to indicate it can't write to the .php_cs.cache file. When I try setting "simple-php-cs-fixer.usingCache": false vscode is telling me it's an unknown option.
I'm seeing the same issue as @redenz.
From the console:
Failed to write file ".php_cs.cache", "no reason available".
Is there a way to disable the cache?
I'm getting the same error. macOS 10.14.1, VSCode 1.29.1.
As a workaround, I was able to disable the cache in my config file:
<?php
return PhpCsFixer\Config::create()
->setUsingCache(false);
Any thoughts on how we could fix this in the plugin? I get the same error. Maybe add a flag to the command? Or do something with permissions?
I don't know much about VS Code extensions. Unless getArgs() isn't working for some reason, it looks like removing lines 35-37 would turn off caching always.
For some reason, the usingCache
(and rules
) aren't showing up in VS Code. I tried adding
"simple-php-cs-fixer.usingCache": false
to my user settings, but it still doesn't work.
How are you folks seeing the errors? I'm getting the unknown error when I try to use a config file .php_cs.dist
that I made from the Laravel gist
vscode developer console
On Feb 26, 2020, at 6:51 PM, Erin Dalzell [email protected] wrote:
How are you folks seeing the errors? I'm getting the unknown error when I try to use a config file .php_cs.dist that I made from the Laravel gist
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
The Debug Console? Nothing is shown when I run it, unfortunately.
Not the debug console. There’s VSCode developer tools. I think it’s under the help menu. It will open up a chrome developer console and show you the errors.
On Feb 26, 2020, at 7:37 PM, Erin Dalzell [email protected] wrote:
The Debug Console? Nothing is shown when I run it, unfortunately.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

So there's an error AND it seems to be loading the default, yet double quotes are not being converted to single quotes as per the default.
If I run it from the command line it DOES work though, so it's somehow not being applied to the current file.
If I take out my rule and turn off the custom config there are no errors yet the file is NOT processed. WTH.
Was anyone able to solve this? I keep getting the same error as well. 😢
I get this error everyone once in a while and it just breaks my projects. Any solutions?