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

Ruff Server errors when using a VSCode interactive session #11851

Closed
MichaReiser opened this issue Jun 13, 2024 · 2 comments · Fixed by #11942
Closed

Ruff Server errors when using a VSCode interactive session #11851

MichaReiser opened this issue Jun 13, 2024 · 2 comments · Fixed by #11942
Assignees
Labels
bug Something isn't working server Related to the LSP server

Comments

@MichaReiser
Copy link
Member

Apologies for commenting on a closed ticket, but it looks to be related:
There seems to be a similar issue when using a VSCode interactive session (VSCode > Run Current File in Interactive Window or Create Interactive Window:

My local Ruff is on 0.4.8

2024-06-12 16:23:08.468 [info] Name: Ruff
2024-06-12 16:23:08.468 [info] Module: ruff
2024-06-12 16:23:08.469 [info] Python extension loading
2024-06-12 16:23:08.469 [info] Waiting for interpreter from python extension.
2024-06-12 16:23:08.469 [info] Python extension loaded
2024-06-12 16:23:08.469 [info] Server run command: $HOME/.local/bin/ruff server --preview
2024-06-12 16:23:08.469 [info] Server: Start requested.
2024-06-12 16:23:08.567 [info]    0.843883s INFO ruff_server::server Configuration file watcher successfully registered

2024-06-12 16:23:26.985 [info]   19.307727s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings
  19.308549s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive

2024-06-12 16:23:28.934 [info]   21.293249s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings

2024-06-12 16:23:28.934 [info]   21.293530s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive

2024-06-12 16:23:29.143 [info]   21.488888s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings
  21.489236s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive
  21.489315s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings
  21.489531s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive

2024-06-12 16:23:29.225 [info]   21.576600s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings
  21.578133s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive
  21.578433s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings
  21.578733s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive

2024-06-12 16:23:30.044 [info]   22.403670s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings

2024-06-12 16:23:30.045 [info]   22.404434s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive
  22.404564s WARN ruff_server::session::index No settings available for untitled:/Interactive-1.interactive - falling back to default settings

2024-06-12 16:23:30.045 [info]   22.404794s DEBUG ruff_server::lint Ignored path via `exclude`: /Interactive-1.interactive

I've attempted excluding the interactive file type via my user settings like the below, but warnings still loop:

{
...
    "ruff.path": ["$HOME/.local/bin/ruff"],
    "ruff.exclude": ["*.interactive"],
    "ruff.nativeServer": true,
}

What the logs look like when ruff.nativeServer is disabled:

2024-06-12 16:31:11.131 [info] Name: Ruff
2024-06-12 16:31:11.131 [info] Module: ruff
2024-06-12 16:31:11.131 [info] Python extension loading
2024-06-12 16:31:11.131 [info] Waiting for interpreter from python extension.
2024-06-12 16:31:11.131 [info] Python extension loaded
2024-06-12 16:31:11.131 [info] Server run command: $HOME/.micromamba/envs/seg/bin/python $HOME/.vscode-server/extensions/charliermarsh.ruff-2024.26.0-linux-x64/bundled/tool/server.py
2024-06-12 16:31:11.131 [info] Server: Start requested.
2024-06-12 16:31:11.360 [info] 2024-06-12 16:31:11,285 INFO Starting IO server

2024-06-12 16:31:11.431 [info] Workspace settings: [
    {
        "nativeServer": false,
        "cwd": "$HOME/Dev/projects/seg-2023/seg_2023",
        "workspace": "file://$HOME/Dev/projects/seg-2023/seg_2023",
        "path": [
            "$HOME/.local/bin/ruff"
        ],
        "ignoreStandardLibrary": true,
        "interpreter": [
            "$HOME/.micromamba/envs/seg/bin/python"
        ],
        "configuration": null,
        "importStrategy": "fromEnvironment",
        "codeAction": {
            "fixViolation": {
                "enable": true
            },
            "disableRuleComment": {
                "enable": true
            }
        },
        "lint": {
            "enable": true,
            "run": "onType",
            "args": [],
            "preview": null,
            "select": null,
            "extendSelect": null,
            "ignore": null
        },
        "format": {
            "args": [],
            "preview": null
        },
        "enable": true,
        "organizeImports": true,
        "fixAll": true,
        "showNotifications": "off",
        "exclude": null,
        "lineLength": null,
        "configurationPreference": "editorFirst"
    }
]
2024-06-12 16:31:11.433 [info] Global settings: {
    "nativeServer": false,
    "cwd": "$HOME/AppData/Local/Programs/Microsoft VS Code",
    "workspace": "$HOME/AppData/Local/Programs/Microsoft VS Code",
    "path": [
        "$HOME/.local/bin/ruff"
    ],
    "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"
}
2024-06-12 16:31:11.576 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:11.601 [info] Inferred version 0.4.8 for: $HOME/.local/bin/ruff
2024-06-12 16:31:11.614 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:11.617 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '$HOME/Dev/projects/seg-2023/seg_2023/src/seg_2023/config.py']
2024-06-12 16:31:31.659 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:31.673 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:31.676 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:33.781 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:33.804 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:33.836 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:33.842 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:33.842 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:33.842 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:33.843 [info] 2024-06-12 16:31:33,842 WARNING Cancel notification for unknown message id "6"

2024-06-12 16:31:33.844 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:33.844 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:33.844 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:33.845 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:33.845 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:33.845 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:33.846 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:33.846 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:33.846 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:34.037 [info] 2024-06-12 16:31:34,036 WARNING Cancel notification for unknown message id "8"

2024-06-12 16:31:34.176 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:34.177 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:34.177 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']
2024-06-12 16:31:34.183 [info] Using 'path' setting: $HOME/.local/bin/ruff
2024-06-12 16:31:34.184 [info] Found ruff 0.4.8 at $HOME/.local/bin/ruff
2024-06-12 16:31:34.185 [info] Running Ruff with: $HOME/.local/bin/ruff ['check', '--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--stdin-filename', '/Interactive-1.interactive']

Originally posted by @pep-sanwer in #11674 (comment)

@MichaReiser MichaReiser added the server Related to the LSP server label Jun 13, 2024
@MichaReiser
Copy link
Member Author

@pep-sanwer What kind of error do you see? Does VS Code show you an error pop up?

I'm asking because I don't see any errors in the log

@charliermarsh charliermarsh added the bug Something isn't working label Jun 13, 2024
@snowsignal snowsignal self-assigned this Jun 13, 2024
@pep-sanwer
Copy link

pep-sanwer commented Jun 13, 2024

Thank you for moving my comment to a ticket @MichaReiser

I'm regularly seeing VSCode error popups indicating that:
Ruff encountered a problem. Check the logs for more details.

I was able to see some ERROR log lines from the Ruff extension on closing the Interactive session:

2024-06-13 11:26:56.831 [info]   76.724577s WARN ruff_server::session::index No settings available for vscode-notebook-cell:/Interactive-1.interactive#W1sdW50aXRsZWQ%3D - falling back to default settings
  76.724912s ERROR ruff_server::server::api An error occurred while running textDocument/didClose: Unable to take snapshot for document with URL vscode-notebook-cell:/Interactive-1.interactive#W1sdW50aXRsZWQ%3D
  76.725010s WARN ruff_server::session::index No settings available for vscode-notebook-cell:/Interactive-1.interactive#W2sdW50aXRsZWQ%3D - falling back to default settings
  76.725166s ERROR ruff_server::server::api An error occurred while running textDocument/didClose: Unable to take snapshot for document with URL vscode-notebook-cell:/Interactive-1.interactive#W2sdW50aXRsZWQ%3D
  76.725211s WARN ruff_server::session::index No settings available for vscode-notebook-cell:/Interactive-1.interactive#W3sdW50aXRsZWQ%3D - falling back to default settings
  76.725343s ERROR ruff_server::server::api An error occurred while running textDocument/didClose: Unable to take snapshot for document with URL vscode-notebook-cell:/Interactive-1.interactive#W3sdW50aXRsZWQ%3D
  76.725392s WARN ruff_server::session::index No settings available for vscode-notebook-cell:/Interactive-1.interactive#W4sdW50aXRsZWQ%3D - falling back to default settings
  76.725517s ERROR ruff_server::server::api An error occurred while running textDocument/didClose: Unable to take snapshot for document with URL vscode-notebook-cell:/Interactive-1.interactive#W4sdW50aXRsZWQ%3D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Related to the LSP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants