vscode-php-cs-fixer
vscode-php-cs-fixer copied to clipboard
junstyle.php-cs-fixer provider failed
Im using vscode insiders on windows 10 and if I use version 0.1.143 everything works ok, but if I update to any newer version I get that error. Do I have to config anything extra in the newer versions?
can you paste your develop tools logs menu: about ->develop tools
2020-04-13 19:54:50.739] [exthost] [error] [junstyle.php-cs-fixer] provider FAILED [2020-04-13 19:54:50.739] [exthost] [error] undefined [2020-04-13 19:54:50.812] [exthost] [error] [junstyle.php-cs-fixer] provider FAILED [2020-04-13 19:54:50.812] [exthost] [error] undefined [2020-04-13 19:54:50.822] [exthost] [error] onWillSaveTextDocument-listener from extension 'junstyle.php-cs-fixer' threw ERROR [2020-04-13 19:54:50.822] [exthost] [error] undefined
[Extension Host]% (6) ["c:\Users\Simon\.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.143\php-cs-fixer.phar", "fix", "--using-cache=no", "C:\Users\Simon\AppData\Local\Temp/ReportesController.php", "--rules=@PSR2", "--path-mode=override"]0: "c:\Users\Simon\.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.143\php-cs-fixer.phar"1: "fix"2: "--using-cache=no"3: "C:\Users\Simon\AppData\Local\Temp/ReportesController.php"4: "--rules=@PSR2"5: "--path-mode=override"length: 6__proto__: Array(0) (at PHPCSFixer.getArgs (c:\Users\Simon\.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.143\extension.js:131:17))
I want to see the log generated by version newer then 0.1.143
or >0.1.143 there are no logs like these?
[Extension Host]% (6) ["c:\Users\Simon\.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.143\php-cs-fixer.phar", "fix", "--using-cache=no",
Is it this one? notificationsAlerts.ts:40 PHP CS Fixer: Configuration error of the application. onDidChangeNotification @ notificationsAlerts.ts:40
console.error(toErrorMessage(e.item.message.linkedText.toString(), true));
Or this one
[Extension Host] Error: ENOENT: no such file or directory, open 'C:\Users\Simon\AppData\Local\Temp/ReportesController.php' at Object.openSync (fs.js:447:3) at Object.func (electron/js2c/asar.js:140:31) at Object.func [as openSync] (electron/js2c/asar.js:140:31) at Object.readFileSync (fs.js:349:35) at Object.fs.readFileSync (electron/js2c/asar.js:542:40) at Object.fs.readFileSync (electron/js2c/asar.js:542:40) at ChildProcess.
not found this file: C:\Users\Simon\AppData\Local\Temp/ReportesController.php this extension generated a tmp file, write to tmp directory failed? can you find this file?
Yes that was my bad I was having trouble with my connection and got d/c and the file I was editing was from an ftp. Sorry about not finding the right errors I will keep using 0.1.143 which is the one that works for me, I tried 0.1.150 which was uploaded like an hour ago and that doesn't throw any errors but won't fix the file either. Don't want to waste your time and thanks a lot for actually helping me.
Just as a last thought this error is on 0.1.149 notificationsAlerts.ts:40 Command 'php-cs-fixer: fix this file' resulted in an error (command 'php-cs-fixer.fix' not found) onDidChangeNotification @ notificationsAlerts.ts:40
This extension is completely unreliable. Anyone knows any alternative? I have the same problem, over and over... FAILED without any reason.
I got the same error and investigate a little.
Investigation
Apparently, the extension uses a local ".phar" and I also have an instance of php-cs-fixer in my vendor.
The logged error is
[Error]
Call to undefined method PhpCsFixer\Tokenizer\Tokens::getTokenNotOfKindsSibling()
PhpCsFixer\Fixer\Import\OrderedImportsFixer->getNewOrder()
in phar:///home/jdeniau/.vscode-server/extensions/junstyle.php-cs-fixer-0.1.157/php-cs-fixer.phar/src/Fixer/Import/OrderedImportsFixer.php at line 191
PhpCsFixer\Fixer\Import\OrderedImportsFixer->applyFix()
in phar:///home/jdeniau/.vscode-server/extensions/junstyle.php-cs-fixer-0.1.157/php-cs-fixer.phar/src/AbstractFixer.php at line 75
PhpCsFixer\AbstractFixer->fix()
in /home/jdeniau/code/ticketing/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php at line 190
PhpCsFixer\Runner\Runner->fixFile()
in /home/jdeniau/code/ticketing/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php at line 132
PhpCsFixer\Runner\Runner->fix()
in phar:///home/jdeniau/.vscode-server/extensions/junstyle.php-cs-fixer-0.1.157/php-cs-fixer.phar/src/Console/Command/FixCommand.php at line 222
PhpCsFixer\Console\Command\FixCommand->execute()
in phar:///home/jdeniau/.vscode-server/extensions/junstyle.php-cs-fixer-0.1.157/php-cs-fixer.phar/vendor/symfony/console/Command/Command.php at line 255
The phar version is 2.16.8 and my local version is 2.15.3
In the 2.16.8, the getTokenNotOfKindsSibling method exists, it does not in 2.15.3
So I think there is a conflict between my vendor and the phar version
Override configuration
In my configuration, I tried to override the php-cs-fixer.executablePath to set my local version of php-cs-fixer, but I now have the following error :
PHP CS Fixer: executablePath not found, please check your settings. It will set to built-in php-cs-fixer.phar. Try again!
The executed command is
[Extension Host]% (5) ["fix", "--using-cache=no", "/tmp/DenormalizeBatchCommand.php", "--config=/home/jdeniau/code/ticketing/.php_cs", "--path-mode=override"]
The executablePath is missing (with the default configuration, there is a leading "/home/jdeniau/.vscode-server/extensions/junstyle.php-cs-fixer-0.1.157/php-cs-fixer.phar")
Extension override configuration
And it automatically reset the value to ${extensionPath}/php-cs-fixer.phar, and then we go to the first error.
I hope it can help you !
Temporary fix
Upgrading my vendor to php-cs-fixer 2.17.0 (😕) does fix the problem temporarily
@jdeniau no need vender code files, use phar , if you config executablePath
We have a pre-commit hook that uses the vendor php-cs-fixer files to format code that was not writter with VSCode with this extension. VSCode is just a « helper » that will do the job while coding for those who prefer that 😉
@jdeniau thank you for your investigation!
I am now using the following setting to force the extension to use the php-cs-fixer of my project:
${workspaceFolder}/vendor/bin/php-cs-fixer
${workspaceFolder}/vendor/bin/php-cs-fixer
@oliverpool I'm having this problem too. May I ask where you typed this? Was it in here?
Doing something similar to the above got my phpcs working for passive code highlighting, but the "fix" command doesn't work.
Your screenshot seems to show another extension.
Can you search for php-cs-fixer.executablePath? (Or add it manually under .vscode/settings.json)