astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
945 stars 45 forks source link

"There is no formatter for 'python' files installed." #460

Open samuela opened 2 months ago

samuela commented 2 months ago

I have just installed the extension and reloaded my VSCode window. However, when attempted Cmd+P => Format document, I'm now faced with an error modal dialog:

Screenshot 2024-04-26 at 4 17 12 PM
charliermarsh commented 2 months ago

Have you tried setting the following in your settings.json?

{
    "[python]": {
        "editor.defaultFormatter": "charliermarsh.ruff"
    }
}
samuela commented 2 months ago

No, but is such a setting necessary to use ruff as a Python formatter?

charliermarsh commented 2 months ago

I don't believe so, but I've also never run into the message you're seeing above once I've installed the extension.

I also just verified that if I uninstall the extension, I see that message; and if I then install it and run "Format Document", the document formats and I see no such message.

Anything other info you can provide? It seems like an issue with the VS Code setup rather than the extension specifically.

samuela commented 2 months ago

Ok I just created a .vscode/settings.json file with the contents of https://github.com/astral-sh/ruff-vscode/issues/460#issuecomment-2080201961 but I'm still getting the same error.

Anything other info you can provide? It seems like an issue with the VS Code setup rather than the extension specifically.

I'm working in a dev container with the ruff extension installed in the container. I'm running on aarch64-darwin. Here is my .devcontainer/devcontainer.json and .devcontainer/Dockerfile.

ma-sadeghi commented 2 months ago

Same issue here: Ubuntu 22.04, used to work before, not sure what changed. Here's the traceback:

2024-05-02 06:57:14.666 [error] Server: Start failed: Error: Unsupported server configuration {
    "args": [
        "/home/amin/.vscode/extensions/charliermarsh.ruff-2024.20.0-linux-x64/bundled/tool/server.py"
    ],
    "options": {
        "cwd": "/home/amin/Code/AutoEIS",
        "env": {
            "ATUIN_SESSION": "018f38f36e14719e855c2bfafec93de4",
            "CHROME_DESKTOP": "code-url-handler.desktop",
            "CONDA_EXE": "/home/amin/miniforge3/bin/conda",
            "CONDA_PYTHON_EXE": "/home/amin/miniforge3/bin/python",
            "CONDA_SHLVL": "0",
            "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus",
            "DEFAULTS_PATH": "/usr/share/gconf/pop.default.path",
            "DESKTOP_SESSION": "pop",
            "DISPLAY": ":1",
            "GDK_BACKEND": "x11",
            "GDMSESSION": "pop",
            "GIO_LAUNCHED_DESKTOP_FILE": "/usr/share/applications/code.desktop",
            "GIO_LAUNCHED_DESKTOP_FILE_PID": "32120",
            "GJS_DEBUG_OUTPUT": "stderr",
            "GJS_DEBUG_TOPICS": "JS ERROR;JS LOG",
            "GNOME_DESKTOP_SESSION_ID": "this-is-deprecated",
            "GNOME_SHELL_SESSION_MODE": "pop",
            "GPG_AGENT_INFO": "/run/user/1000/gnupg/S.gpg-agent:0:1",
            "GTK_IM_MODULE": "ibus",
            "GTK_MODULES": "gail:atk-bridge",
            "HOME": "/home/amin",
            "HOMEBREW_CELLAR": "/home/linuxbrew/.linuxbrew/Cellar",
            "HOMEBREW_PREFIX": "/home/linuxbrew/.linuxbrew",
            "HOMEBREW_REPOSITORY": "/home/linuxbrew/.linuxbrew/Homebrew",
            "INFOPATH": "/home/linuxbrew/.linuxbrew/share/info::/home/amin/Programs/texlive/2023/texmf-dist/doc/info",
            "INVOCATION_ID": "63cde9c7c3c44c6c9f855e835e057f0d",
            "JOURNAL_STREAM": "8:39213",
            "LANG": "en_CA.UTF-8",
            "LANGUAGE": "en_CA:en",
            "LC_ADDRESS": "en_CA.UTF-8",
            "LC_IDENTIFICATION": "en_CA.UTF-8",
            "LC_MEASUREMENT": "en_CA.UTF-8",
            "LC_MONETARY": "en_CA.UTF-8",
            "LC_NAME": "en_CA.UTF-8",
            "LC_NUMERIC": "en_CA.UTF-8",
            "LC_PAPER": "en_CA.UTF-8",
            "LC_TELEPHONE": "en_CA.UTF-8",
            "LC_TIME": "en_CA.UTF-8",
            "LD_LIBRARY_PATH": ":/home/amin/Code/panua-pardiso-20240229-linux/lib",
            "LESSCLOSE": "/usr/bin/lesspipe %s %s",
            "LESSOPEN": "| /usr/bin/lesspipe %s",
            "LM_LICENSE_FILE": "6601@a2.cmc.ca",
            "LOGNAME": "amin",
            "MANAGERPID": "5334",
            "MANDATORY_PATH": "/usr/share/gconf/pop.mandatory.path",
            "MANPATH": "/home/linuxbrew/.linuxbrew/share/man::/home/amin/Programs/texlive/2023/texmf-dist/doc/man:",
            "MODULAR_HOME": "/home/amin/.modular",
            "OPENAI_API_KEY": "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",
            "ORIGINAL_XDG_CURRENT_DESKTOP": "pop:GNOME",
            "PAPERSIZE": "letter",
            "PARDISOLICMESSAGE": "0",
            "PATH": "/home/amin/.local/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/amin/.modular/pkg/packages.modular.com_max/bin:/home/amin/miniforge3/condabin:/home/amin/.rbenv/shims:/home/amin/.rbenv/bin:/home/amin/.rye/shims:/home/amin/.cargo/bin:/home/amin/.juliaup/bin:/home/amin/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/amin/Code/git-filter-repo:/home/amin/.codon/bin:/opt/chromedriver_linux64:/usr/local/cuda-12.3/bin:/home/amin/Programs/texlive/2023/bin/x86_64-linux",
            "PWD": "/home/amin",
            "QT_ACCESSIBILITY": "1",
            "QT_IM_MODULE": "ibus",
            "RBENV_SHELL": "bash",
            "RYE_NO_AUTO_INSTALL": "1",
            "SESSION_MANAGER": "local/zaboor:@/tmp/.ICE-unix/6348,unix/zaboor:/tmp/.ICE-unix/6348",
            "SHELL": "/bin/bash",
            "SHLVL": "0",
            "SSH_AGENT_LAUNCHER": "gnome-keyring",
            "SSH_AUTH_SOCK": "/run/user/1000/keyring/ssh",
            "STARSHIP_SESSION_KEY": "2051624185719320",
            "STARSHIP_SHELL": "bash",
            "SYSTEMD_EXEC_PID": "6377",
            "TERMINFO_DIRS": "/etc/terminfo:/lib/terminfo:/usr/share/terminfo",
            "USER": "amin",
            "USERNAME": "amin",
            "VSCODE_AMD_ENTRYPOINT": "vs/workbench/api/node/extensionHostProcess",
            "VSCODE_CODE_CACHE_PATH": "/home/amin/.config/Code/CachedData/e170252f762678dec6ca2cc69aba1570769a5d39",
            "VSCODE_CRASH_REPORTER_PROCESS_TYPE": "extensionHost",
            "VSCODE_CWD": "/home/amin",
            "VSCODE_HANDLES_UNCAUGHT_ERRORS": "true",
            "VSCODE_IPC_HOOK": "/run/user/1000/vscode-94f0baa7-1.88-main.sock",
            "VSCODE_NLS_CONFIG": "{\"locale\":\"en-gb\",\"osLocale\":\"en-ca\",\"availableLanguages\":{},\"_languagePackSupport\":true}",
            "VSCODE_PID": "32120",
            "WINDOWPATH": "2",
            "XAUTHORITY": "/run/user/1000/gdm/Xauthority",
            "XDG_CONFIG_DIRS": "/etc/xdg/xdg-pop:/etc/xdg",
            "XDG_CURRENT_DESKTOP": "Unity",
            "XDG_DATA_DIRS": "/usr/share/pop:/usr/share/gnome:/home/amin/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop",
            "XDG_MENU_PREFIX": "gnome-",
            "XDG_RUNTIME_DIR": "/run/user/1000",
            "XDG_SESSION_CLASS": "user",
            "XDG_SESSION_DESKTOP": "pop",
            "XDG_SESSION_TYPE": "x11",
            "XMODIFIERS": "@im=ibus",
            "_": "/usr/share/code/code",
            "ELECTRON_RUN_AS_NODE": "1",
            "APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL": "1",
            "VSCODE_L10N_BUNDLE_LOCATION": "",
            "USE_DEBUGPY": "False",
            "LS_SHOW_NOTIFICATION": "off"
        }
    }
}
ma-sadeghi commented 2 months ago

Never mind. Mine was a strange one, I was working in a VS Code workspace with two folders, just removed one (AutoEIS, which is cwd in the trace back), restarted Ruff server, added it back and voila!