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

'Unknown Error' #1

Open
ohnotnow opened this issue Oct 29, 2017 · 19 comments
Open

'Unknown Error' #1

ohnotnow opened this issue Oct 29, 2017 · 19 comments

Comments

@ohnotnow
Copy link

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 ;-)

@ohnotnow
Copy link
Author

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 :-)

@calebporzio
Copy link
Owner

What happens if you run:
php-cs-fixer fix yourfile.php --config=/Users/ohffs/Documents/code/project/.php_cs.dist?

@ohnotnow
Copy link
Author

ohnotnow commented Nov 1, 2017

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 : vysker/vscode-php-formatter#15

@calebporzio
Copy link
Owner

By any chance, are you on windows? - I just uploaded a fix that makes this extension cross-platform

@ohnotnow
Copy link
Author

ohnotnow commented Nov 3, 2017

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 :-)

@calebporzio
Copy link
Owner

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!

@ohnotnow
Copy link
Author

ohnotnow commented Nov 9, 2017

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 ;-)

@redenz
Copy link

redenz commented Dec 9, 2017

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.

@cashlion
Copy link

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?

@jamesratcliffe
Copy link

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);

@calebporzio
Copy link
Owner

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?

@jamesratcliffe
Copy link

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.

@edalzell
Copy link

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

@redenz
Copy link

redenz commented Feb 27, 2020 via email

@edalzell
Copy link

The Debug Console? Nothing is shown when I run it, unfortunately.

@redenz
Copy link

redenz commented Feb 27, 2020 via email

@edalzell
Copy link

image

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.

@brada1703
Copy link

Was anyone able to solve this? I keep getting the same error as well. 😢
image

@ghost
Copy link

ghost commented Oct 19, 2021

I get this error everyone once in a while and it just breaks my projects. Any solutions?

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

7 participants