astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.13k stars 54 forks source link

Multi project workspace with poetry venvs result in "Unsuported server configuration" error #240

Open leddy231 opened 1 year ago

leddy231 commented 1 year ago

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

2023-06-20 15:11:35.229 [info] Name: Ruff
2023-06-20 15:11:35.229 [info] Module: ruff
2023-06-20 15:11:35.229 [info] Python extension loading
2023-06-20 15:11:35.229 [info] Waiting for interpreter from python extension.
2023-06-20 15:11:36.036 [info] Python extension loaded
2023-06-20 15:11:38.216 [info] Server run command:  /home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/bundled/tool/server.py
2023-06-20 15:11:38.216 [info] Server: Start requested.
2023-06-20 15:11:38.219 [info] [Error - 3:11:38 PM] Ruff client: couldn't create connection to server.
2023-06-20 15:11:38.219 [info] Error: Unsupported server configuration {
    "args": [
        "/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/bundled/tool/server.py"
    ],
    "options": {
        "cwd": "/home/martin/ruff_multiroot_test",
        "env": {
            "ASDF_DIR": "/home/martin/.asdf",
            "CHROME_DESKTOP": "code-url-handler.desktop",
            "COLORTERM": "truecolor",
            "COMPIZ_CONFIG_PROFILE": "gnome-flashback",
            "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus",
            "DEBUGINFOD_URLS": "https://debuginfod.ubuntu.com ",
            "DESKTOP_AUTOSTART_ID": "103e5e9bed3e08c4bf168726171799393000000053800016",
            "DESKTOP_SESSION": "regolith",
            "DISPLAY": ":0",
            "ELECTRON_NO_ATTACH_CONSOLE": "1",
            "GDK_BACKEND": "x11",
            "GDMSESSION": "regolith",
            "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop",
            "GIO_LAUNCHED_DESKTOP_FILE_PID": "72752",
            "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated",
            "GNOME_TERMINAL_SCREEN": "/org/gnome/Terminal/screen/2aa16ef4_874a_44d9_a16f_b8ba7bd97c44",
            "GNOME_TERMINAL_SERVICE": ":1.240",
            "GPG_AGENT_INFO": "/run/user/1000/gnupg/S.gpg-agent:0:1",
            "GTK_MODULES": "gail:atk-bridge",
            "HOME": "/home/martin",
            "I3SOCK": "/run/user/1000/i3/ipc-socket.5745",
            "LANG": "en_US.UTF-8",
            "LC_ADDRESS": "sv_SE.UTF-8",
            "LC_IDENTIFICATION": "sv_SE.UTF-8",
            "LC_MEASUREMENT": "sv_SE.UTF-8",
            "LC_MONETARY": "sv_SE.UTF-8",
            "LC_NAME": "sv_SE.UTF-8",
            "LC_NUMERIC": "sv_SE.UTF-8",
            "LC_PAPER": "sv_SE.UTF-8",
            "LC_TELEPHONE": "sv_SE.UTF-8",
            "LC_TIME": "sv_SE.UTF-8",
            "LESS": "-R",
            "LOGNAME": "martin",
            "LSCOLORS": "Gxfxcxdxbxegedabagacad",
            "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
            "NO_AT_BRIDGE": "1",
            "OLDPWD": "/home/martin",
            "ORIGINAL_XDG_CURRENT_DESKTOP": "sway",
            "PAGER": "less",
            "PATH": "/home/martin/.local/bin:/home/martin/.asdf/shims:/home/martin/.asdf/bin:/home/martin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin",
            "PWD": "/home/martin/ruff_multiroot_test",
            "QT_ACCESSIBILITY": "1",
            "QT_IM_MODULE": "ibus",
            "SESSION_MANAGER": "local/martin-eliteboook:@/tmp/.ICE-unix/5380,unix/martin-eliteboook:/tmp/.ICE-unix/5380",
            "SHELL": "/usr/bin/zsh",
            "SHLVL": "1",
            "SSH_AGENT_PID": "125481",
            "SSH_AUTH_SOCK": "/tmp/ssh-XXXXXX9wDaF4/agent.125480",
            "SYSTEMD_EXEC_PID": "5124",
            "TERM": "xterm-256color",
            "USER": "martin",
            "USERNAME": "martin",
            "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
            "VSCODE_CLI": "1",
            "VSCODE_CODE_CACHE_PATH": "/home/martin/.config/Code/CachedData/695af097c7bd098fbf017ce3ac85e09bbc5dda06",
            "VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
            "VSCODE_CWD": "/home/martin/ruff_multiroot_test",
            "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
            "VSCODE_IPC_HOOK": "/run/user/1000/vscode-6379ee7e-1.79-main.sock",
            "VSCODE_NLS_CONFIG": "{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
            "VSCODE_PID": "72752",
            "VTE_VERSION": "7000",
            "WINDOWPATH": "2",
            "XAUTHORITY": "/run/user/1000/gdm/Xauthority",
            "XDG_CONFIG_DIRS": "/etc/xdg/xdg-regolith:/etc/xdg",
            "XDG_CURRENT_DESKTOP": "sway",
            "XDG_DATA_DIRS": "/usr/share/regolith:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop",
            "XDG_MENU_PREFIX": "gnome-flashback-",
            "XDG_RUNTIME_DIR": "/run/user/1000",
            "XDG_SESSION_CLASS": "user",
            "XDG_SESSION_DESKTOP": "regolith",
            "XDG_SESSION_TYPE": "x11",
            "XMODIFIERS": "@im=ibus",
            "ZSH": "/home/martin/.oh-my-zsh",
            "_": "/usr/bin/code",
            "ELECTRON_RUN_AS_NODE": "1",
            "APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1",
            "USE_DEBUGPY": "False",
            "LS_SHOW_NOTIFICATION": "off"
        }
    }
}
    at stdioEncoding (/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/node/main.js:466:98)
    at b.LogMessageNotification [as createConnection] (/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/common/client.js:1094:83)
    at b.start (/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/node_modules/vscode-languageclient/lib/common/client.js:635:72)
    at runServer (/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/src/common/server.ts:118:16)
    at checkIfConfigurationChanged (/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/src/extension.ts:158:15)
    at /home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/dist/webpack:/ruff/src/extension.ts:179:11
2023-06-20 15:11:38.219 [error] Server: Start failed: Error: Unsupported server configuration {
    "args": [
        "/home/martin/.vscode/extensions/charliermarsh.ruff-2023.26.0-linux-x64/bundled/tool/server.py"
    ],
    "options": {
        "cwd": "/home/martin/ruff_multiroot_test",
        "env": {
            "ASDF_DIR": "/home/martin/.asdf",
            "CHROME_DESKTOP": "code-url-handler.desktop",
            "COLORTERM": "truecolor",
            "COMPIZ_CONFIG_PROFILE": "gnome-flashback",
            "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus",
            "DEBUGINFOD_URLS": "https://debuginfod.ubuntu.com ",
            "DESKTOP_AUTOSTART_ID": "103e5e9bed3e08c4bf168726171799393000000053800016",
            "DESKTOP_SESSION": "regolith",
            "DISPLAY": ":0",
            "ELECTRON_NO_ATTACH_CONSOLE": "1",
            "GDK_BACKEND": "x11",
            "GDMSESSION": "regolith",
            "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop",
            "GIO_LAUNCHED_DESKTOP_FILE_PID": "72752",
            "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated",
            "GNOME_TERMINAL_SCREEN": "/org/gnome/Terminal/screen/2aa16ef4_874a_44d9_a16f_b8ba7bd97c44",
            "GNOME_TERMINAL_SERVICE": ":1.240",
            "GPG_AGENT_INFO": "/run/user/1000/gnupg/S.gpg-agent:0:1",
            "GTK_MODULES": "gail:atk-bridge",
            "HOME": "/home/martin",
            "I3SOCK": "/run/user/1000/i3/ipc-socket.5745",
            "LANG": "en_US.UTF-8",
            "LC_ADDRESS": "sv_SE.UTF-8",
            "LC_IDENTIFICATION": "sv_SE.UTF-8",
            "LC_MEASUREMENT": "sv_SE.UTF-8",
            "LC_MONETARY": "sv_SE.UTF-8",
            "LC_NAME": "sv_SE.UTF-8",
            "LC_NUMERIC": "sv_SE.UTF-8",
            "LC_PAPER": "sv_SE.UTF-8",
            "LC_TELEPHONE": "sv_SE.UTF-8",
            "LC_TIME": "sv_SE.UTF-8",
            "LESS": "-R",
            "LOGNAME": "martin",
            "LSCOLORS": "Gxfxcxdxbxegedabagacad",
            "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
            "NO_AT_BRIDGE": "1",
            "OLDPWD": "/home/martin",
            "ORIGINAL_XDG_CURRENT_DESKTOP": "sway",
            "PAGER": "less",
            "PATH": "/home/martin/.local/bin:/home/martin/.asdf/shims:/home/martin/.asdf/bin:/home/martin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin",
            "PWD": "/home/martin/ruff_multiroot_test",
            "QT_ACCESSIBILITY": "1",
            "QT_IM_MODULE": "ibus",
            "SESSION_MANAGER": "local/martin-eliteboook:@/tmp/.ICE-unix/5380,unix/martin-eliteboook:/tmp/.ICE-unix/5380",
            "SHELL": "/usr/bin/zsh",
            "SHLVL": "1",
            "SSH_AGENT_PID": "125481",
            "SSH_AUTH_SOCK": "/tmp/ssh-XXXXXX9wDaF4/agent.125480",
            "SYSTEMD_EXEC_PID": "5124",
            "TERM": "xterm-256color",
            "USER": "martin",
            "USERNAME": "martin",
            "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
            "VSCODE_CLI": "1",
            "VSCODE_CODE_CACHE_PATH": "/home/martin/.config/Code/CachedData/695af097c7bd098fbf017ce3ac85e09bbc5dda06",
            "VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
            "VSCODE_CWD": "/home/martin/ruff_multiroot_test",
            "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
            "VSCODE_IPC_HOOK": "/run/user/1000/vscode-6379ee7e-1.79-main.sock",
            "VSCODE_NLS_CONFIG": "{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
            "VSCODE_PID": "72752",
            "VTE_VERSION": "7000",
            "WINDOWPATH": "2",
            "XAUTHORITY": "/run/user/1000/gdm/Xauthority",
            "XDG_CONFIG_DIRS": "/etc/xdg/xdg-regolith:/etc/xdg",
            "XDG_CURRENT_DESKTOP": "sway",
            "XDG_DATA_DIRS": "/usr/share/regolith:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop",
            "XDG_MENU_PREFIX": "gnome-flashback-",
            "XDG_RUNTIME_DIR": "/run/user/1000",
            "XDG_SESSION_CLASS": "user",
            "XDG_SESSION_DESKTOP": "regolith",
            "XDG_SESSION_TYPE": "x11",
            "XMODIFIERS": "@im=ibus",
            "ZSH": "/home/martin/.oh-my-zsh",
            "_": "/usr/bin/code",
            "ELECTRON_RUN_AS_NODE": "1",
            "APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1",
            "USE_DEBUGPY": "False",
            "LS_SHOW_NOTIFICATION": "off"
        }
    }
}
charliermarsh commented 1 year ago

Thanks for the repo, I will take a look.

charliermarsh commented 1 year ago

Hmm, I followed the instructions (which are great!) and it worked without issue for me:

Screen Shot 2023-06-20 at 11 16 22 AM
charliermarsh commented 1 year ago

\cc @karthiknadig just for visibility

leddy231 commented 1 year ago

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.

karthiknadig commented 1 year ago

@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.

bigluck commented 1 year ago

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 :(

bersbersbers commented 1 year ago

Selecting an interpreter for the root folder fixes the issue.

Thank you, that's a neat workaround that works for me and hopefully others.

inigohidalgo commented 1 year ago

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.

AxelVoitier commented 10 months ago

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?

Here is output of Ruff extension during one of the failed attempt (I think this one was with useBundled). ``` 2024-01-25 09:56:00.164 [info] Server run command: /home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/bundled/tool/server.py 2024-01-25 09:56:00.165 [info] Server: Start requested. 2024-01-25 09:56:00.165 [info] [Error - 9:56:00 AM] Ruff client: couldn't create connection to server. 2024-01-25 09:56:00.165 [info] Error: Unsupported server configuration { "args": [ "/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/bundled/tool/server.py" ], "options": { "cwd": "/home/lexa/PATH/TO/JAVA/PROJECT", "env": { "PYENV_VIRTUALENV_INIT": "1", "USER": "lexa", "SSH_CLIENT": "xxx.xxx.xxx.xxx 33446 xxx", "LC_TIME": "fr_FR.UTF-8", "XDG_SESSION_TYPE": "tty", "SHLVL": "1", "MOTD_SHOWN": "pam", "HOME": "/home/lexa", "PYENV_SHELL": "bash", "LC_MONETARY": "fr_FR.UTF-8", "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", "LOGNAME": "lexa", "_": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/node", "XDG_SESSION_CLASS": "user", "XDG_SESSION_ID": "8239", "PATH": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/remote-cli:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/shims:/home/lexa/.local/bin:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/bin:/home/lexa/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin", "VSCODE_AGENT_FOLDER": "/home/lexa/.vscode-server", "LC_ADDRESS": "fr_FR.UTF-8", "XDG_RUNTIME_DIR": "/run/user/1000", "DISPLAY": "localhost:10.0", "LANG": "en_US.UTF-8", "LC_TELEPHONE": "fr_FR.UTF-8", "SSH_AUTH_SOCK": "/run/user/1000/vscode-ssh-auth-sock-97782932", "SHELL": "/bin/bash", "LC_NAME": "fr_FR.UTF-8", "LC_MEASUREMENT": "fr_FR.UTF-8", "LC_IDENTIFICATION": "fr_FR.UTF-8", "PWD": "/home/lexa", "SSH_CONNECTION": "xxx.xxx.xxx.xxx 33446 xxx.xxx.xxx.xxx xxx", "PYENV_ROOT": "/home/lexa/.pyenv", "XDG_DATA_DIRS": "/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop", "LC_NUMERIC": "fr_FR.UTF-8", "LC_PAPER": "fr_FR.UTF-8", "VSCODE_HANDLES_SIGPIPE": "true", "LS_COLORS": "", "LESSCLOSE": "/usr/bin/lesspipe %s %s", "LESSOPEN": "| /usr/bin/lesspipe %s", "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess", "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true", "VSCODE_NLS_CONFIG": "{\"locale\":\"en\",\"osLocale\":\"en\",\"availableLanguages\":{}}", "BROWSER": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/helpers/browser.sh", "VSCODE_CWD": "/home/lexa", "ELECTRON_RUN_AS_NODE": "1", "VSCODE_IPC_HOOK_CLI": "/run/user/1000/vscode-ipc-8e1b8f9c-eee0-44bc-a2bc-2451931a42f4.sock", "APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1", "VSCODE_L10N_BUNDLE_LOCATION": "", "USE_DEBUGPY": "False", "LS_SHOW_NOTIFICATION": "off" } } } at /home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:304410 at async b.createConnection (/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:139724) at async b.start (/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:130239) at async t.restartServer (/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:54104) at async S (/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:391301) at async f.value (/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/dist/extension.js:1:391853) 2024-01-25 09:56:00.165 [error] Server: Start failed: Error: Unsupported server configuration { "args": [ "/home/lexa/.vscode-server/extensions/charliermarsh.ruff-2024.2.0-linux-x64/bundled/tool/server.py" ], "options": { "cwd": "/home/lexa/PATH/TO/JAVA/PROJECT", "env": { "PYENV_VIRTUALENV_INIT": "1", "USER": "lexa", "SSH_CLIENT": "xxx.xxx.xxx.xxx 33446 xxx", "LC_TIME": "fr_FR.UTF-8", "XDG_SESSION_TYPE": "tty", "SHLVL": "1", "MOTD_SHOWN": "pam", "HOME": "/home/lexa", "PYENV_SHELL": "bash", "LC_MONETARY": "fr_FR.UTF-8", "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", "LOGNAME": "lexa", "_": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/node", "XDG_SESSION_CLASS": "user", "XDG_SESSION_ID": "8239", "PATH": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/remote-cli:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/shims:/home/lexa/.local/bin:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/plugins/pyenv-virtualenv/shims:/home/lexa/.pyenv/bin:/home/lexa/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin", "VSCODE_AGENT_FOLDER": "/home/lexa/.vscode-server", "LC_ADDRESS": "fr_FR.UTF-8", "XDG_RUNTIME_DIR": "/run/user/1000", "DISPLAY": "localhost:10.0", "LANG": "en_US.UTF-8", "LC_TELEPHONE": "fr_FR.UTF-8", "SSH_AUTH_SOCK": "/run/user/1000/vscode-ssh-auth-sock-97782932", "SHELL": "/bin/bash", "LC_NAME": "fr_FR.UTF-8", "LC_MEASUREMENT": "fr_FR.UTF-8", "LC_IDENTIFICATION": "fr_FR.UTF-8", "PWD": "/home/lexa", "SSH_CONNECTION": "xxx.xxx.xxx.xxx 33446 xxx.xxx.xxx.xxx xxx", "PYENV_ROOT": "/home/lexa/.pyenv", "XDG_DATA_DIRS": "/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop", "LC_NUMERIC": "fr_FR.UTF-8", "LC_PAPER": "fr_FR.UTF-8", "VSCODE_HANDLES_SIGPIPE": "true", "LS_COLORS": "", "LESSCLOSE": "/usr/bin/lesspipe %s %s", "LESSOPEN": "| /usr/bin/lesspipe %s", "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess", "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true", "VSCODE_NLS_CONFIG": "{\"locale\":\"en\",\"osLocale\":\"en\",\"availableLanguages\":{}}", "BROWSER": "/home/lexa/.vscode-server/bin/8b3775030ed1a69b13e4f4c628c612102e30a681/bin/helpers/browser.sh", "VSCODE_CWD": "/home/lexa", "ELECTRON_RUN_AS_NODE": "1", "VSCODE_IPC_HOOK_CLI": "/run/user/1000/vscode-ipc-8e1b8f9c-eee0-44bc-a2bc-2451931a42f4.sock", "APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1", "VSCODE_L10N_BUNDLE_LOCATION": "", "USE_DEBUGPY": "False", "LS_SHOW_NOTIFICATION": "off" } } } ```
karthiknadig commented 10 months ago

@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.

iulica commented 9 months ago

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 commented 8 months ago

@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.

niderhoff commented 5 months ago

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?

MichaReiser commented 5 months ago

@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.