Open cogerk opened 6 days ago
Try this setting: black-formatter.serverTransport
to stdio
. if it is already stdio
then try pipe
Thanks for the quick response.
I tried both stdio and pipe and it looks like I get the same log message after rebooting/saving a file I want to format:
2024-06-26 15:45:57.945 [info] Formatting requested before server has started.
Here's my new settings file:
{
"workbench.colorTheme": "Nu Disco Dark",
"codeium.enableConfig": {
"*": true,
"markdown": true
},
"remote.autoForwardPortsSource": "hybrid",
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"notebook.defaultFormatter": "ms-python.black-formatter",
"notebook.formatOnSave.enabled": true,
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic",
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.inlayHints.functionReturnTypes": true,
"black-formatter.serverTransport": "pipe",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.formatOnType": true
},
}
I will bed the full log to see exactly what the error is.
Sure thing, is the log given in the issue post missing information? (under 'Click Here for Detailed Log') How can I get that full log for you?
@cogerk Sorry I missed that.
Can you check if there is a bundled/tool directory here: /home/kanadig/.vscode-server/extensions/ms-python.black-formatter-2024.3.11501016/bundled/tool
I am using insiders version the version you have might be different.
Typically, there should be a server start line:
Alrighty, here's what I have in that dir
In a terminal can you run this:
/home/kc/src/.venv/bin/python ~/.vscode-server/extensions/ms-python.black-formatter-2024.2.0/bundled/tool/lsp_server.py
It should just run and not crash.
This is a very strange case where nothing is erroring out in a way that is telling me what is failing. Typically, the lsp_server.py
script fails or the communication between VS Code and LSP server fails. When that happens there is a obvious "Error" that you can see in the logs. But in this scenario, it is not running anything.
It looks like it runs and just hangs, but it doesn't crash! Is that expected behavior? It doesn't auto format on save while running either
That is expected. This means it can run, something else is broken. Can you try installing the pre-release version? you can use this command or from the extension view you can switch to pre-release.
If that also doesn't work, we can try an equivalent extension `Ruff', and see if that loads.
Diagnostic Data
Behaviour
Expected vs. Actual Behavior
I expected black to automatically format this test.py file on save, but nothing happens.
Trying to restart the black server yields an error:![image](https://github.com/microsoft/vscode-black-formatter/assets/9560816/b4589374-5d41-4302-a957-075559716c2b)
Reproduction Steps:
Here's my user settings json:
And my remote json:
Logs:
Click here for detailed logs
``` 2024-06-26 14:50:15.734 [info] Name: Black Formatter 2024-06-26 14:50:15.734 [info] Module: black 2024-06-26 14:50:15.734 [info] Default formatter is set to ms-python.black-formatter for workspace /home/kc 2024-06-26 14:50:15.734 [info] Python extension loading 2024-06-26 14:50:15.734 [info] Waiting for interpreter from python extension. 2024-06-26 14:50:15.734 [info] No interpreter found from setting black-formatter.interpreter 2024-06-26 14:50:15.734 [info] Getting interpreter from ms-python.python extension for workspace /home/kc 2024-06-26 14:50:15.734 [info] Python extension loaded 2024-06-26 14:50:15.734 [info] Interpreter from ms-python.python extension for /home/kc: /home/kc/src/.venv/bin/python 2024-06-26 14:50:15.734 [info] Workspace settings for /home/kc (client side): { "cwd": "/home/kc", "workspace": "file:///home/kc", "args": [], "path": [], "interpreter": [ "/home/kc/src/.venv/bin/python" ], "importStrategy": "useBundled", "showNotifications": "off" } 2024-06-26 14:50:15.734 [info] No interpreter found from setting black-formatter.interpreter 2024-06-26 14:50:15.734 [info] Getting interpreter from ms-python.python extension for workspace /home/kc 2024-06-26 14:50:15.734 [info] Interpreter from ms-python.python extension for /home/kc: /home/kc/src/.venv/bin/python 2024-06-26 14:50:15.734 [info] Workspace settings for /home/kc (client side): { "cwd": "/home/kc", "workspace": "file:///home/kc", "args": [], "path": [], "interpreter": [ "/home/kc/src/.venv/bin/python" ], "importStrategy": "useBundled", "showNotifications": "off" } 2024-06-26 14:50:15.734 [info] Global settings (client side): { "cwd": "/mnt/c/Users/coger/AppData/Local/Programs/Microsoft VS Code", "workspace": "/mnt/c/Users/coger/AppData/Local/Programs/Microsoft VS Code", "args": [], "path": [], "interpreter": [], "importStrategy": "useBundled", "showNotifications": "off" } 2024-06-26 14:50:21.122 [info] Formatting requested before server has started. ```Outcome When Attempting Debugging Steps:
ctrl-F "command" and "running" in my trace log output found 0 results
Extra Details
Other Extensions:
I also posted this on stack overflow first: https://stackoverflow.com/questions/78634195/wsl2-vscode-black-extension-isnt-formatting-on-save
Thanks for your insights!