junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
353 stars 42 forks source link

Notification of breaking api change with v1.92 release of VS Code #212

Closed deepak1556 closed 1 month ago

deepak1556 commented 2 months ago

Hello from the VS Code team 👋

In our next release v1.92, we will update to Electron 30 which includes Node.js 20.14.0. This Node version contains a breaking change, in response to a CVE, which may affect you if you execute .bat or .cmd files on Windows. Based on a simple scan of your extension's source code, you may be impacted by this change. The stable VS Code that contains this update will be released in early August.

Action: please try out your extension on this month's VS Code Insiders on Windows. If you are affected by this change, you will encounter an EINVAL error when you try to spawn a bat/cmd file.

Node.js has added a section on batch file spawning to their documentation. To fix any issues:

  1. Find locations where you call child_process.spawn to execute a batch file on Windows
  2. Add shell: true or shell: process.platform === 'win32' to the options object
  3. If the batch script path may contain spaces, you will also need to wrap the path in quotation marks.

Please let us know if you run into issues or if you need clarification.

Happy coding!

MircoBabin commented 1 month ago

@junstyle I can confirm that php-cs-fixer does not work anymore with the july 2024 (1.92.0) update of vs code.

It would be great if this can be resolved somehow. For now I downgraded to the june 2024 version - https://github.com/microsoft/vscode/issues/224550#issuecomment-2264770627. I have no immediate problem. But I do want to upgrade to newer versions. So it would be great if you can find some time to dive into this.

Thanks in advance!

walangkaji commented 1 month ago

while waiting for this extension update, here's how I make it working: edit the index.js in C:\Users\username\.vscode\junstyle.php-cs-fixer-0.3.13 find the keyword of ".spawn" and add shell=true; in 3rd parameter of the function,

// Before:
... function Rn(t,e,i,s=null){let n=(0,sg.spawn)(t,e,i),r=new Promise((o,h) ....

// After:
... function Rn(t,e,i,s=null){i.shell=true;let n=(0,sg.spawn)(t,e,i),r=new Promise((o,h) ....

in my case I just add i.shell=true; save and then reload the vscode (Ctrl+Shift+P -> Reload Window)

wshaver commented 1 month ago

What @walangkaji posted works in both insiders and main builds of vscode. Thank you!