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

Can't format with Pint extension #72

Open
shawinigan opened this issue Jan 31, 2025 · 13 comments
Open

Can't format with Pint extension #72

shawinigan opened this issue Jan 31, 2025 · 13 comments
Labels
bug Something isn't working

Comments

@shawinigan
Copy link

Describe the bug
When trying to format a PHP file with the pint extension it doesn't work.
When I'm doing it with through this command it works : php ./vendor/bin/pint

To Reproduce
Steps to reproduce the behavior:

  1. Go in a PHP file
  2. do ctrl+shift+p
  3. Select "format file with..."
  4. see the error in the second image

Expected behavior
It should format the file.

Screenshots
When selecting option "format file with... "
Image
it gives this error:
Image

These are the errors in the extensions logs:
2025-01-31 16:50:20.732 [error] [open-southeners.laravel-pint] provider FAILED
2025-01-31 16:50:20.733 [error] TypeError: The "file" argument must be of type string. Received null
at normalizeSpawnArguments (node:child_process:549:3)
at spawn (node:child_process:789:13)
at re.run (c:\Users\pmbaril.vscode\extensions\open-southeners.laravel-pint-1.3.0\out\extension.js:7:10545)
at wi.formatFile (c:\Users\pmbaril.vscode\extensions\open-southeners.laravel-pint-1.3.0\out\extension.js:9:77352)
at gs.provideEdits (c:\Users\pmbaril.vscode\extensions\open-southeners.laravel-pint-1.3.0\out\extension.js:9:75578)
at N$.provideDocumentFormattingEdits (file:///c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:135051)

Environment:

  • Operating system: Windows 11 24H2 build 26120.1843
  • IDE / version: VSCode 1.96.4 (system setup)
  • Extension version: 1.3.0
  • PHP: 8.2.19
  • laravel/framework": "^11.31
  • laravel/pint": "^1.20
  • Extension's config:

Image

Additional context
Here's all the things I've tried:

  1. Running VSCode as an administrator
  2. Reinstalling the extension
  3. Changing permission to the folder of the extension
  4. Running it manually like this: vendor\bin\pint.bat ide_helpers\Helper.php (and it works)
  5. Made sure that the default formatter for PHP was: "editor.defaultFormatter": "open-southerners.laravel-pint"
@shawinigan shawinigan added the bug Something isn't working label Jan 31, 2025
@mselmanyildirim
Copy link

I have the same issue here.

System info:

  • OS: win 10
  • VScode: tried both 1.93.0 and 1.96.2 versions
  • Extension version: 1.3.0 (Auto update enabled)
  • Laravel: v10.45.1
  • php: 8.2.23
  • pint: tried both 1.14.0 and 1.20.0

settings.json:

{
    "laravel-pint.enable": true,
    "[php]": {
        "editor.defaultFormatter": "open-southeners.laravel-pint",
    },
    "editor.formatOnSave": true
}

Symptoms:

  • Format on save doesn't work (if default formatter is changed to another formatter, other formatter works)
  • ctrl+shift+p Format Document doesn't work
  • ctrl+shift+p Format Document With... Laravel Pint doesn't work with a pop up saying "The file argument must be of type string. Received null"
  • ./vendor/bin/pint <file-path> works

Note:
Since this break happened recently and I was using the extension without issues before, I suspect this is related to the latest update of extension.

@mselmanyildirim
Copy link

Edit: Verified that the issue is related to the latest release 1.3.0 by rolling back to the previous release 1.2.1.

@shawinigan
Copy link
Author

Thanks for that, it's working for me too with version 1.2.1 .

@d8vjork
Copy link
Member

d8vjork commented Feb 6, 2025

This might be related to #67

@d8vjork
Copy link
Member

d8vjork commented Feb 6, 2025

Can't replicate anyway on my Windows 10 machine using 1.3.0

Image

@shawinigan @mselmanyildirim Mind sharing the path to the file you guys got issues with?

@crazynds
Copy link

crazynds commented Feb 7, 2025

Same error. Changing the version work for me.

@mselmanyildirim
Copy link

mselmanyildirim commented Feb 11, 2025

@d8vjork sorry for delayed answer.
Standard output shows nothing when I press ctrl + s. Extension host output shows the following:

Image

For the file path, I can't format any of the files in the project, so I can share a random one: app\Http\Controllers\Controller.php

To test further, I have created a fresh project (so this time laravel version is v11.41.3), made a single edit to make code wrongly formatted and I tried to format the file without success. Full file path is C:\test\pintExtensionTest\app\Models\User.php

When I rollback to version 1.2.1 of the extension, I can format in both the old project and the new project.
Would you like me to look at anywhere else for more detailed debug logs etc?

Edit: I don't have a customized pint.json file by the way. I haven't created any.

@d8vjork
Copy link
Member

d8vjork commented Feb 11, 2025

@mselmanyildirim Weird, I'll probably need to dig deeper on this as on my 2 laptops doesn't happen. Having last version on the extension

@mselmanyildirim
Copy link

I'm unable to see this log you shared showing the 'command'. Can I easily get this log? If I get it, there may be more information.

Image

I don't get this log neither in 1.2.1 nor in 1.3.0

@d8vjork
Copy link
Member

d8vjork commented Feb 11, 2025

@mselmanyildirim That's when you set the laravel-pint.enableDebugLogs extension setting on VSCode

Then in the "Output" tab should appear "Laravel Pint" on the dropdown of the right side

@mselmanyildirim
Copy link

@d8vjork Thanks. Tried with debug logs but seems nothing useful there:

["DEBUG" - 1:38:09 PM] Config files found on workspace
{
  "workspace": "c:\\test\\pintExtensionTest",
  "found": [
    "C:\\test\\pintExtensionTest\\pint.json"
  ]
}

@d8vjork
Copy link
Member

d8vjork commented Feb 12, 2025

@mselmanyildirim Does it output something else when saving?

@mselmanyildirim
Copy link

mselmanyildirim commented Feb 12, 2025

@d8vjork
When saving with extension 1.2.1, says

["DEBUG" - 5:14:34 PM] Config files found on workspace
{
  "workspace": "c:\\test\\pintExtensionTest",
  "found": [
    "C:\\test\\pintExtensionTest\\pint.json"
  ]
}
["DEBUG" - 5:14:34 PM] Formatting file(s) using Pint
{
  "command": "php vendor/bin/pint --config C:\\test\\pintExtensionTest\\pint.json c:\\test\\pintExtensionTest\\app\\Models\\User.php"
}
["INFO" - 5:14:34 PM] Formatting completed in 251ms.

But when saving with 1.3.0, only says

["DEBUG" - 5:16:44 PM] Config files found on workspace
{
  "workspace": "c:\\test\\pintExtensionTest",
  "found": [
    "C:\\test\\pintExtensionTest\\pint.json"
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants