vscode-php-cs-fixer icon indicating copy to clipboard operation
vscode-php-cs-fixer copied to clipboard

junstyle.php-cs-fixer provider failed

Open simongas opened this issue 5 years ago • 13 comments

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?

simongas avatar Apr 13 '20 16:04 simongas

can you paste your develop tools logs menu: about ->develop tools

junstyle avatar Apr 13 '20 22:04 junstyle

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

simongas avatar Apr 14 '20 01:04 simongas

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",

junstyle avatar Apr 14 '20 02:04 junstyle

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. (c:\Users\Simon.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.150\index.js:1:164960) at ChildProcess.emit (events.js:203:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) (at c:\Users\Simon.vscode-insiders\extensions\junstyle.php-cs-fixer-0.1.150\index.js:1:168866)

simongas avatar Apr 14 '20 02:04 simongas

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?

junstyle avatar Apr 14 '20 02:04 junstyle

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

simongas avatar Apr 14 '20 03:04 simongas

This extension is completely unreliable. Anyone knows any alternative? I have the same problem, over and over... FAILED without any reason.

gremo avatar Jun 01 '20 09:06 gremo

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 avatar Dec 08 '20 08:12 jdeniau

@jdeniau no need vender code files, use phar , if you config executablePath

junstyle avatar Dec 08 '20 08:12 junstyle

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 avatar Dec 08 '20 08:12 jdeniau

@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

oliverpool avatar Aug 11 '21 08:08 oliverpool

${workspaceFolder}/vendor/bin/php-cs-fixer

@oliverpool I'm having this problem too. May I ask where you typed this? Was it in here?

image

Doing something similar to the above got my phpcs working for passive code highlighting, but the "fix" command doesn't work.

image

NovemLinguae avatar Feb 21 '23 23:02 NovemLinguae

Your screenshot seems to show another extension. Can you search for php-cs-fixer.executablePath? (Or add it manually under .vscode/settings.json)

oliverpool avatar Feb 22 '23 06:02 oliverpool