astral-sh/ruff-vscode

Ruff Native server not working In the latest version

zhengyu-yang opened this issue · 16 comments

Ruff Version: 2024.34.0
VS Code Version:1.91.1 Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729

Ruff Setting:

"ruff.nativeServer": true

After the latest update, the ruff lsp server will not start. The log looks like:

2024-07-23 14:17:50.822 [info] Name: Ruff
2024-07-23 14:17:50.822 [info] Module: ruff

All formatting command does not have any response.

Can you try running Ruff: Restart server in VS Code?

The server started after Ruff: Restart server . However, when try to format a document, it shows Ruff does not recognize this file. Also, 2024.30.0 works fine.

@zhengyu-yang Do you have any other ruff.* settings set apart from ruff.nativeServer ? Can you provide a screenshot of the VS Code toolbar which is present at the bottom of the window? This mentions the Python version and environment. If possible, can we connect on Discord or another platform? We've been seeing this a lot but unable to reproduce it.

@zhengyu-yang Can you try the pre-release version and check if it's still occurring?

Screenshot 2024-07-24 at 10 28 16

I face the same issue.

I face the same issue.

Can you please provide what issue you're facing along with the details about your setup and settings?

My setup is:

Version: 1.92.0-insider
Commit: 22e3447b4b410dcf8426bf70743c5dd4030d6122
Date: 2024-07-23T05:03:52.385Z (1 day ago)
Platform: Windows 10 and WSL2.

I am facing the exact same issue. Recently Ruff stopped working properly. When I start VS Code, Ruff fails to start and I get the following output:

2024-07-24 10:36:48.143 [info] Name: Ruff
2024-07-24 10:36:48.143 [info] Module: ruff

In order to get it working I have to either select Ruff: Restart Server or change the setting ruff.nativeServer from on to auto or vice versa. In that case, I get the following output:

2024-07-24 10:36:48.143 [info] Name: Ruff
2024-07-24 10:36:48.143 [info] Module: ruff
2024-07-24 10:37:23.800 [info] Falling back to bundled executable: /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.34.0-linux-x64/bundled/libs/bin/ruff
2024-07-24 10:37:23.820 [info] Found Ruff 0.5.3 at /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.34.0-linux-x64/bundled/libs/bin/ruff
2024-07-24 10:37:23.820 [info] Server run command: /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.34.0-linux-x64/bundled/libs/bin/ruff server
2024-07-24 10:37:23.821 [info] Server: Start requested.
    "[python]": {
        "editor.wordWrap": "off",
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit",
            // "source.fixAll": "explicit"
        },
        "editor.rulers": [
            {
                "column": 79
            },
        ],
    },
    "python.languageServer": "Jedi",
    "python.analysis.autoImportCompletions": true,
    "python.analysis.completeFunctionParens": true,
    "ruff.nativeServer": "on",
    "ruff.lineLength": 79,
    "ruff.interpreter": [
        "/opt/conda/bin/python",
        "/opt/conda/bin/python3",
    ]

@Adam-Antios Thank you for the details. I can see that you're using the latest stable version of the extension. Can you try this on the pre-release version? You can do so by clicking on the "Switch to Pre-Release Version" in the VS Code marketplace (image reference: #555 (comment))?

In the pre-release version Ruff seems to work properly.

Thank you for trying it out and confirming. It must've been fixed by #553.

I also tried to switch to pre-release. Interestingly, if I have unsupported settings in ruff.lint.args, the native server wont start initially. The extension seems to hang when the notification (unsupported settings used with the native server. Refer to the logs for more details) pops up. After I dismiss the notification, the extension start to work.

@zhengyu-yang Thanks for trying out the pre-release version and sharing that. That scenario is fixed in #557 and I'm about to release a new version.

Hi @zhengyu-yang, @Adam-Antios we just released a new stable version (2024.36.0) with all the bug fixes. Can you try it out?

It seems to work as intended! Thank you for your great work. Since I discovered Ruff I am impressed by its performance and would hate to have to go back to other alternatives.

The output of Ruff during startup:

2024-07-25 09:51:53.349 [info] Name: Ruff
2024-07-25 09:51:53.349 [info] Module: ruff
2024-07-25 09:51:53.349 [info] Using interpreter: /opt/conda/bin/python /opt/conda/bin/python3
2024-07-25 09:51:53.897 [info] Falling back to bundled executable: /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.36.0-linux-x64/bundled/libs/bin/ruff
2024-07-25 09:51:53.918 [info] Found Ruff 0.5.4 at /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.36.0-linux-x64/bundled/libs/bin/ruff
2024-07-25 09:51:53.918 [info] Server run command: /home/vscode/.vscode-server-insiders/extensions/charliermarsh.ruff-2024.36.0-linux-x64/bundled/libs/bin/ruff server
2024-07-25 09:51:53.920 [info] Server: Start requested.

Now it seems to start the server as intended. If you need further diagnostics feel free to ask me as I don't really know what else I could provide.

This looks good! Thank you for confirming. I'll mark this issue as resolved.

The issue that the author is facing is also resolved: #555 (comment)