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

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

Closed
samuela opened this issue Apr 26, 2024 · 22 comments
Closed

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

samuela opened this issue Apr 26, 2024 · 22 comments
Labels
devcontainer Related to VS Code dev container (https://code.visualstudio.com/docs/devcontainers/containers)

Comments

@samuela
Copy link

samuela commented Apr 26, 2024

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
Copy link
Member

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

{
    "[python]": {
        "editor.defaultFormatter": "charliermarsh.ruff"
    }
}

@samuela
Copy link
Author

samuela commented Apr 26, 2024

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

@charliermarsh
Copy link
Member

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
Copy link
Author

samuela commented Apr 28, 2024

Ok I just created a .vscode/settings.json file with the contents of #460 (comment) 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
Copy link

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
Copy link

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!

@MalteHB
Copy link

MalteHB commented Jul 22, 2024

Got the same error message but downgraded to the version v2024.30.0 which fixed it.

@dhruvmanila dhruvmanila added the devcontainer Related to VS Code dev container (https://code.visualstudio.com/docs/devcontainers/containers) label Jul 23, 2024
@dhruvmanila
Copy link
Member

@MalteHB are you using VS Code dev containers where you're facing this? If not, can you open a new issue for it with all the relevant details about your setup and config?

@neuromaancer
Copy link

neuromaancer commented Jul 23, 2024

Got the same error message but downgraded to the version v2024.30.0 which fixed it.

I can confirm this. I used Remoted SSH and the Ruff can't be loaded, no special setting I made. Downgrading works for me!

It works btw locally with the newest version.

@kasi-mir33
Copy link

kasi-mir33 commented Jul 23, 2024

I have the same issue and despite downgrading to v2024.30.0 it still doesn't seem to work like it used to.

I had already added "editor.defaultFormatter": "charliermarsh.ruff" to my settings before

I'm using VS code locally.

image

image

@MichaReiser
Copy link
Member

MichaReiser commented Jul 23, 2024

I wonder if the ruff server fails to start for some reason and, as a result thereof, the formatter capability doesn't get registered.

Would you mind sharing the Ruff logs with us by opening the logs and then run Ctrl+Shift+P - Ruff: Print debug information

https://github.com/astral-sh/ruff-vscode?tab=readme-ov-file#troubleshooting

@dhruvmanila
Copy link
Member

In addition to the logs,

  • What happens if you run the "Ruff: Format document" command?
  • Do you still see the diagnostics provided by Ruff?

@kasi-mir33
Copy link

kasi-mir33 commented Jul 23, 2024

@MichaReiser

This only worked after downgrading to v2024.30.0, when I tried to print debug information on the newest update nothing happened.

024-07-23 19:17:00.895 [info] [Trace - 7:17:00 PM] Sending request 'workspace/executeCommand - (1)'.
2024-07-23 19:17:00.895 [info] Params: {
    "command": "ruff.printDebugInformation"
}

2024-07-23 19:17:00.897 [info] [Trace - 7:17:00 PM] Received notification 'window/logMessage'.
2024-07-23 19:17:00.897 [info] Params: {
    "message": "executable = C:\\Users\\***\\AppData\\Roaming\\Python\\Python311\\Scripts\\ruff.exe\nversion = 0.5.4\nencoding = UTF16\nopen_document_count = 0\nactive_workspace_count = 2\nconfiguration_files = [\"c:\\\\Users\\\\***\\\\Meine Ablage\\\\***\\\\***\\\\ruff.toml\", \"c:\\\\git\\\\***\\\\ruff.toml\"]\ncapabilities.code_action_deferred_edit_resolution = true\ncapabilities.apply_edit = true\ncapabilities.document_changes = true\ncapabilities.workspace_refresh = true\ncapabilities.pull_diagnostics = true\n",
    "type": 3
}

2024-07-23 19:17:00.897 [info] [Info  - 7:17:00 PM] executable = C:\Users\***\AppData\Roaming\Python\Python311\Scripts\ruff.exe
version = 0.5.4
encoding = UTF16
open_document_count = 0
active_workspace_count = 2
configuration_files = ["c:\\Users\\***\\Meine Ablage\\***\\***\\ruff.toml", "c:\\git\\***\\ruff.toml"]
capabilities.code_action_deferred_edit_resolution = true
capabilities.apply_edit = true
capabilities.document_changes = true
capabilities.workspace_refresh = true
capabilities.pull_diagnostics = true

2024-07-23 19:17:00.898 [info] [Trace - 7:17:00 PM] Received response 'workspace/executeCommand - (1)' in 2ms.
2024-07-23 19:17:00.898 [info] No result returned.

@dhruvmanila

now I feel like an idiot. Not sure what I messed up earlier.
The hotkey simply worked just now, and "Ruff: Format Document" as well.

On v2024.30.0 though.

@dhruvmanila
Copy link
Member

now I feel like an idiot. Not sure what I messed up earlier. The hotkey simply worked just now, and "Ruff: Format Document" as well.

On v2024.30.0 though.

Does it work on the latest VS Code version?

@kasi-mir33
Copy link

kasi-mir33 commented Jul 23, 2024

now I feel like an idiot. Not sure what I messed up earlier. The hotkey simply worked just now, and "Ruff: Format Document" as well.
On v2024.30.0 though.

Does it work on the latest VS Code version?

No. I just updated and double-checked again.

@dhruvmanila
Copy link
Member

@kasi-mir33 Can you provide what's your setup is like? What are the extension settings that you've set? And, the full logs with the following settings:

{
	"ruff.trace.server": "messages",
	"ruff.logLevel": "debug"
}

@skj-skj
Copy link

skj-skj commented Jul 24, 2024

for temporary solution I am using ruff cli to format files.

ruff format ./path/to/python/file
# or
python -m ruff format ./path/to/python/file

make sure you have installed the ruff using pip

pip install --upgrade ruff

ruff formatter docs: https://docs.astral.sh/ruff/formatter/

@MichaReiser
Copy link
Member

Any chance that you were seeing the native server enabled but using deprecated settings dialogue? If so, can you try to close it to see if Ruff then starts? See #557

@dhruvmanila
Copy link
Member

Hi, to all the users who've subscribed to this issue, we've released a new version (2024.36.0). Can you all try that out and check if the issue that you're facing is resolved or not? We'd appreciate any feedback regarding that.

@skj-skj
Copy link

skj-skj commented Jul 26, 2024

Hi, to all the users who've subscribed to this issue, we've released a new version (2024.36.0). Can you all try that out and check if the issue that you're facing is resolved or not? We'd appreciate any feedback regarding that.

Resolved

@issam-seghir
Copy link

issam-seghir commented Aug 29, 2024

i have the same problem using the latest vrsion : v2024.42.0 and ruff = "^0.6.2"

@dhruvmanila
Copy link
Member

@issam-seghir can you open a new issue with necessary details about your environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devcontainer Related to VS Code dev container (https://code.visualstudio.com/docs/devcontainers/containers)
Projects
None yet
Development

No branches or pull requests

10 participants