Open leddy231 opened 1 year ago
Thanks for the repo, I will take a look.
Hmm, I followed the instructions (which are great!) and it worked without issue for me:
\cc @karthiknadig just for visibility
Did some more digging, think I figured out what is happening
From my logs, this line
Server run command: /home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/bundled/tool/server.py
Is supposed to print the command
and args
for the server settings.
Since there is no .venv for the root folder in the workspace, there is no valid python interpreter for that folder.
https://github.com/astral-sh/ruff-vscode/blob/563b79c375e48b076a22d4611567a183378c8111/src/common/server.ts#L31
This returns undefined. It looks like ruff chooses to start the server in the root folder for some reason. Selecting an interpreter for the root folder fixes the issue. Running the Python: Clear cache and reload window
command in VSCode clears the selected interpreter for the root folder, and the issue comes back.
I guess it would be nice with an error message from ruff here, something along the lines of No python interpreter selected for $folder
. It would also maybe make sense to pick the correct interpreter for files in each folder, this is at least what the Python Language server does. (you can check the outputs from the python lsp to see it starting 3 services for the 3 folders in the workspace). Although I would not expect many repos where the ruff version would differ between folders.
@charliermarsh I will make an update to the extension template that should address this issue. You can open a tracking issue on the template repository if you like.
I'm facing a similar problem with my workspace. What's strange is that it stopped working this Monday, but it worked perfectly last week.
2023-09-22 10:25:04.579 [info] Name: Ruff
2023-09-22 10:25:04.579 [info] Module: ruff
2023-09-22 10:25:04.579 [info] Python extension loading
2023-09-22 10:25:04.579 [info] Waiting for interpreter from python extension.
2023-09-22 10:25:04.579 [info] Python extension loaded
2023-09-22 10:25:11.559 [info] Server run command: /Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/bundled/tool/server.py
2023-09-22 10:25:11.559 [info] Server: Start requested.
2023-09-22 10:25:11.566 [info] [Error - 10:25:11] Ruff client: couldn't create connection to server.
2023-09-22 10:25:11.567 [info] Error: Unsupported server configuration {
"args": [
"/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/bundled/tool/server.py"
],
"options": {
"cwd": "/Users/bigluck/Dev/my-project",
"env": {
"COMMAND_MODE": "unix2003",
"HOME": "/Users/bigluck",
"LOGNAME": "bigluck",
"MallocNanoZone": "0",
"ORIGINAL_XDG_CURRENT_DESKTOP": "undefined",
"PATH": "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin",
"SHELL": "/bin/zsh",
"SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.1fFv10Siml/Listeners",
"TMPDIR": "/var/folders/t4/s10mxgh14hsbr_lkb5sbg5r00000gn/T/",
"USER": "bigluck",
"VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
"VSCODE_CODE_CACHE_PATH": "/Users/bigluck/Library/Application Support/Code/CachedData/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d",
"VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
"VSCODE_CWD": "/",
"VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
"VSCODE_IPC_HOOK": "/Users/bigluck/Library/Application Support/Code/1.82-main.sock",
"VSCODE_NLS_CONFIG": "{\"locale\":\"en-gb\",\"osLocale\":\"en-it\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
"VSCODE_PID": "2540",
"XPC_FLAGS": "0x0",
"XPC_SERVICE_NAME": "application.com.microsoft.VSCode.14057624.14057630",
"__CFBundleIdentifier": "com.microsoft.VSCode",
"__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x0",
"ELECTRON_RUN_AS_NODE": "1",
"APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1",
"USE_DEBUGPY": "False",
"LS_SHOW_NOTIFICATION": "always"
}
}
}
at stdioEncoding (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/node/main.js:466:98)
at b.LogMessageNotification [as createConnection] (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/common/client.js:1094:83)
at b.start (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/common/client.js:635:72)
at runServer (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/src/common/server.ts:123:16)
at checkIfConfigurationChanged (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/src/extension.ts:130:15)
at n.value (/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/dist/webpack:/ruff/src/extension.ts:151:11)
2023-09-22 10:25:11.567 [error] Server: Start failed: Error: Unsupported server configuration {
"args": [
"/Users/bigluck/.vscode/extensions/charliermarsh.ruff-2023.38.0-darwin-arm64/bundled/tool/server.py"
],
"options": {
"cwd": "/Users/bigluck/Dev/my-project",
"env": {
"COMMAND_MODE": "unix2003",
"HOME": "/Users/bigluck",
"LOGNAME": "bigluck",
"MallocNanoZone": "0",
"ORIGINAL_XDG_CURRENT_DESKTOP": "undefined",
"PATH": "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin",
"SHELL": "/bin/zsh",
"SSH_AUTH_SOCK": "/private/tmp/com.apple.launchd.1fFv10Siml/Listeners",
"TMPDIR": "/var/folders/t4/s10mxgh14hsbr_lkb5sbg5r00000gn/T/",
"USER": "bigluck",
"VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
"VSCODE_CODE_CACHE_PATH": "/Users/bigluck/Library/Application Support/Code/CachedData/abd2f3db4bdb28f9e95536dfa84d8479f1eb312d",
"VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
"VSCODE_CWD": "/",
"VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
"VSCODE_IPC_HOOK": "/Users/bigluck/Library/Application Support/Code/1.82-main.sock",
"VSCODE_NLS_CONFIG": "{\"locale\":\"en-gb\",\"osLocale\":\"en-it\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
"VSCODE_PID": "2540",
"XPC_FLAGS": "0x0",
"XPC_SERVICE_NAME": "application.com.microsoft.VSCode.14057624.14057630",
"__CFBundleIdentifier": "com.microsoft.VSCode",
"__CF_USER_TEXT_ENCODING": "0x1F5:0x0:0x0",
"ELECTRON_RUN_AS_NODE": "1",
"APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1",
"USE_DEBUGPY": "False",
"LS_SHOW_NOTIFICATION": "always"
}
}
}
The project.code-workspace
file contains:
{
"settings": {
"ruff.organizeImports": true,
"ruff.importStrategy": "fromEnvironment",
}
}
and each project folder contains a .vscode/settings.json
file with:
{
"mypy.dmypyExecutable": "${workspaceFolder}/.venv/bin/dmypy",
"mypy.enabled": true,
"python.analysis.diagnosticMode": "openFilesOnly",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.poetryPath": "${workspaceFolder}/.devenv/profile/bin/poetry",
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"python.testing.cwd": "${workspaceFolder}",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": false,
"python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest",
"python.testing.unittestEnabled": false,
"ruff.path": [
"${workspaceFolder}/.devenv/profile/bin/ruff"
]
}
The project folder is managed using devenv
(nix
) and ruff
is reachable:
$ .devenv/profile/bin/ruff --version
ruff 0.0.278
Ruff is also installed as a dev module on my poetry project:
$ ./.venv/bin/ruff --version
ruff 0.0.290
But still, it stopped working :(
Selecting an interpreter for the root folder fixes the issue.
Thank you, that's a neat workaround that works for me and hopefully others.
Just adding an additional report that this is happening on my machine. Setting a .venv python interpreter for each workspace folder solved the issue for me too.
Hello,
I had this issue as well (in the context of a remote VS code). At first using the bundled Ruff did not work.
What finally did the trick was to remove the few Java project folders I had in my workspace.
Don't really see why/how that made it fail, even when using the bundled one. Especially since many of the other Python project folders I have in that workspace don't have an interpreter configured at all (so, I would assume a non configured python folder should look the same than a java one, but there might be some vs code magic that makes it not so simple).
More strange: I did not had this problem when using VS code on the host machine directly (desktop), with the same multi-language workspace. The only difference I could see here is that I do have java installed on that desktop machine, but not on the one I use to connect remotely to it (laptop). Though, I thought the point of using remote vscode was to use the environment of the remote machine as well?
@AxelVoitier this can happen if python was not able to select a default interpreter for the project as a whole. Try selecting one for the entire workspace case and see if that resumes the server.
I had several folders in the project, and only two of those had python scripts. All folders, and the whole workspace had the same interpreter (.env in the workspace folder) selected. I still got the error, as it automatically selected the wrong folder. I moved the "wrong" folder down in the list and it started working. Maybe this helps someone.
@AxelVoitier this can happen if python was not able to select a default interpreter for the project as a whole. Try selecting one for the entire workspace case and see if that resumes the server.
Update on this: it worked :).
I was in need to include these Java projects in the workspace again. After a disconnection-reconnection (still using with vscode-server), Ruff server stopped working. This time I remembered your comment so I tried to select an interpreter at the workspace level. And that worked. Ruff server restarted fine by itself immediately.
It seems like the ruff-server is crashing if any of the projects in the multi-root workspace has no ruff installed.
in my opinion it should rather not be activated for that project, but enabled in those who do have ruff?
@niderhoff your issue seems different from the issue that the thread author is facing. Would you mind creating a new issue where you include a few more details. What's your setup, what extension version are you using, what are your extension settings.
Background At work we have a large Python monorepo with multiple libraries and services. Each python project has its own pyproject.toml with its own dependencies. We use Poetry with
poetry config virtualenvs.in-project true
to create a virtual environment in each project folder, and a vscode workspace which sets these venvs as the python interpreter for each project. This has worked wonderfully and each opened python file correctly loads the appropriate venv for linting and import resolution.Recently the Ruff extension has stopped working, and with one of the latest extension updates or updates to vscode it now produces a crash log. Ruff works fine if you open one of the projects alone in vscode, but does not work with the workspace. Here is a minimal repo that reproduces the crash: https://github.com/leddy231/ruff_vscode_multiroot
Ruff = 0.0.272 Python = 3.10.4 and 3.11.3 VSCode = 1.79.2 Ruff-extension = 6/20/2023
Here is the full crash output from the extension