vscode-ruff icon indicating copy to clipboard operation
vscode-ruff copied to clipboard

Native server does not work with Jupyter Notebook without configuration

Open Xiao-Chenguang opened this issue 7 months ago • 16 comments

Ruff not function in jupyter notebooks when set ruff.nativeServer to auto or on. It seems there are some communication problem between the nativeserver and notebook. When use ruff-lsp by setting ruff.nativeServer to off, all ruff functions works as expected.

According to the server log, the nativeserver started normally but receive nothing while I type format command.

2024-07-21 16:44:25.149 [info] Name: Ruff
2024-07-21 16:44:25.149 [info] Module: ruff
2024-07-21 16:44:25.149 [info] Python extension loading
2024-07-21 16:44:25.149 [info] Waiting for interpreter from python extension.
2024-07-21 16:44:25.149 [info] Python extension loaded
2024-07-21 16:44:25.242 [info] Falling back to bundled executable: /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff
2024-07-21 16:44:25.265 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2024-07-21 16:44:25.266 [info] Found Ruff 0.5.3 at /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff
2024-07-21 16:44:25.266 [info] Server run command: /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff server
2024-07-21 16:44:25.266 [info] Server: Start requested.

The behaviour of setting nativeServer off is:

2024-07-21 16:48:31.470 [info] Name: Ruff
2024-07-21 16:48:31.470 [info] Module: ruff
2024-07-21 16:48:31.470 [info] Python extension loading
2024-07-21 16:48:31.470 [info] Waiting for interpreter from python extension.
2024-07-21 16:48:31.470 [info] Python extension loaded
2024-07-21 16:48:31.470 [info] Server run command: /Users/cg/miniconda3/envs/fl/bin/python /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/tool/server.py
2024-07-21 16:48:31.470 [info] Server: Start requested.
2024-07-21 16:48:31.934 [info] 2024-07-21 16:48:31,934 INFO Starting IO server

2024-07-21 16:48:31.975 [info] Workspace settings: []
2024-07-21 16:48:31.975 [info] Global settings: {
    "nativeServer": "off",
    "cwd": "/",
    "workspace": "/",
    "path": [],
    "ignoreStandardLibrary": true,
    "interpreter": [],
    "configuration": null,
    "importStrategy": "fromEnvironment",
    "codeAction": {
        "fixViolation": {
            "enable": true
        },
        "disableRuleComment": {
            "enable": true
        }
    },
    "lint": {
        "enable": true,
        "run": "onType",
        "args": []
    },
    "format": {
        "args": []
    },
    "enable": true,
    "organizeImports": true,
    "fixAll": true,
    "showNotifications": "off",
    "configurationPreference": "editorFirst",
    "showSyntaxErrors": true
}
2024-07-21 16:48:31.990 [info] Interpreter executable (/Users/cg/miniconda3/envs/fl/bin/ruff) not found
2024-07-21 16:48:31.990 [info] Falling back to bundled executable: /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff
2024-07-21 16:48:32.025 [info] Inferred version 0.5.3 for: /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff
2024-07-21 16:48:32.025 [info] Found ruff 0.5.3 at /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff
2024-07-21 16:48:32.025 [info] Running Ruff with: /Users/cg/.vscode/extensions/charliermarsh.ruff-2024.34.0-darwin-arm64/bundled/libs/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Users/cg/Desktop/test.ipynb']

other ruff setting: all default ruff version: v2024.34.0 OS: Mac Python version: 3.10

Mininal example:

# test.ipynb
a = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]

Xiao-Chenguang avatar Jul 21 '24 18:07 Xiao-Chenguang