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 · 4 comments · Fixed by #11942
Closed

Ruff Server errors when using a VSCode interactive session #11851

MichaReiser opened this issue Jun 13, 2024 · 4 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

@rcigich
Copy link

rcigich commented Mar 11, 2025

I hate to do this as well. It's starting to feel like a cascade of niche issues. I can't find any mention of this anywhere else, so I will add a comment here first.

I only set general settings for ruff in the vscode settings. I never made a custom, or intentional toml file.

I just noticed that a "pyproject.toml" exists in my project repo under another user's folder, but I think it is erroring out when trying to load.

I also just noticed "charliemarsh." in the "c:\Users~" ruff extensions path. That is not me...is this a normal path to the native server ".vscode\extensions\charliermarsh.ruff-2025.14.0-win32-x64\bundled\libs\bin\ruff.exe"?
Looks like this IS normal

This is starting to feel like I have some latent user settings that I need to exclude...?


I see this error on vscode startup.
Image

The Ruff log looks like this:

2025-03-11 12:30:12.554 [info] Name: Ruff
2025-03-11 12:30:12.554 [info] Module: ruff
2025-03-11 12:30:12.554 [info] Python extension loading
2025-03-11 12:30:12.554 [info] Waiting for interpreter from python extension.
2025-03-11 12:30:12.554 [info] Python extension loaded
2025-03-11 12:30:12.554 [info] Using interpreter: c:\Python310\python.exe
2025-03-11 12:30:14.129 [info] Falling back to bundled executable: c:\Users\project_folder\.vscode\extensions\charliermarsh.ruff-2025.14.0-win32-x64\bundled\libs\bin\ruff.exe
2025-03-11 12:30:14.289 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2025-03-11 12:30:14.293 [info] Found Ruff 0.9.9 at c:\project_folder\.vscode\extensions\charliermarsh.ruff-2025.14.0-win32-x64\bundled\libs\bin\ruff.exe
2025-03-11 12:30:14.293 [info] Server run command: c:\project_folder\.vscode\extensions\charliermarsh.ruff-2025.14.0-win32-x64\bundled\libs\bin\ruff.exe server
2025-03-11 12:30:14.294 [info] Server: Start requested.

The Ruff language server log looks like this:

warning: TCH001 has been remapped to TC001.
2025-03-11 12:30:14.490211800 ERROR Failed to resolve settings for c:\project_folder\users\tjburbac\pyproject.toml: Rule E999 was removed and cannot be selected.
warning: TCH002 has been remapped to TC002.
warning: TCH003 has been remapped to TC003.
warning: TCH004 has been remapped to TC004.
warning: TCH005 has been remapped to TC005.
warning: TCH010 has been remapped to TC010.
2025-03-11 12:30:14.567009700 INFO Registering workspace: c:\project_folder
2025-03-11 12:30:14.755737600 INFO Registering workspace: c:\projects\project_folder
2025-03-11 12:30:14.845222900 INFO Registering workspace: c:\projects\project_folder\lowlevel
2025-03-11 12:30:15.102460200 WARN No settings available for file:///c%3A/Projects/project_folder/DebugCheatSheets/xover.py - falling back to default settings
2025-03-11 12:30:15.105012700 WARN No settings available for file:///c%3A/Projects/project_folder/testflows/blocks/Xover_drift.py - falling back to default settings
2025-03-11 12:30:15.106637800 WARN No settings available for file:///c%3A/Projects/project_folder/DebugCheatSheets/xover.py - falling back to default settings
2025-03-11 12:30:15.106987300 WARN No settings available for file:///c%3A/Projects/project_folder/testflows/blocks/Xover_drift.py - falling back to default settings
2025-03-11 12:30:15.122321700 WARN No settings available for file:///c%3A/Projects/project_folder/DebugCheatSheets/xover.py - falling back to default settings
2025-03-11 12:30:15.122798200 WARN No settings available for file:///c%3A/Projects/project_folder/testflows/blocks/Xover_drift.py - falling back to default settings
2025-03-11 12:30:15.123080200 WARN No settings available for file:///c%3A/Projects/project_folder/DebugCheatSheets/xover.py - falling back to default settings
2025-03-11 12:30:15.123267900 WARN No settings available for file:///c%3A/Projects/project_folder/testflows/blocks/Xover_drift.py - falling back to default settings
2025-03-11 12:30:15.123428400 WARN No settings available for file:///c%3A/Projects/project_folder/DebugCheatSheets/xover.py - falling back to default settings
2025-03-11 12:30:15.123587800 WARN No settings available for file:///c%3A/Projects/project_folder/testflows/blocks/Xover_drift.py - falling back to default settings
2025-03-11 12:30:15.123735200 INFO Configuration file watcher successfully registered


This is the contents of that user's toml file:

[tool.black]
line-length = 160
target-version = ['py310']
include = '\.pyi?$'


[tool.ruff]
target-version = 'py310'
# https://flake8.pycqa.org/en/latest/user/error-codes.html
# This is needs to be kept in sync with the flake8 config
exclude = [
    ".git",
    ".venv",
    ".tox",
    "venv"]
# ruff only support flake8-debugger's rule T100
lint.select = ["F","T", "E999", "T100"]
# skipping unused errors for now: F401, F841
# skip errors due to someone elses __all__ not defined: F403
# dont error just because print is missing
lint.ignore = [
    "F401",
    "F841",
    "F403",
    "T201",
]


[tool.flake8]
# This is needs to be kept in sync with the ruff config
exclude = [
    ".git",
    ".venv",
    ".tox",
    "venv"]
# ruff only support flake8-debugger's rule T100
select = ["F","T"]
# skipping unused errors for now: F401, F841
# skip errors due to someone elses __all__ not defined: F403
# dont error just because print is missing
ignore = [
    "F401",
    "F841",
    "F403",
    "T201",
]

@charliermarsh
Copy link
Member

That is not me...is this a normal path to the native server ".vscode\extensions\charliermarsh.ruff-2025.14.0-win32-x64\bundled\libs\bin\ruff.exe"?

This is normal, yes, because the extension is published under my account as the original creator. (charliermarsh is the "namespace".)

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.

5 participants