astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
30.82k stars 1.02k forks source link

Ruff crashed workspace URL was not a file path! #12660

Closed Odud closed 1 month ago

Odud commented 1 month ago

I'm trying to install and use ruff with Vscode on Windows 10 I've installed ruff with python -m pip install ruff and then the vsode extension but on starting vscode I get the message saying that the Ruff server crashed 5 times in the last 3 minutes. The server will not be restarted. The output looks like this:

2024-08-04 10:36:18.577 [info] Name: Ruff
2024-08-04 10:36:18.577 [info] Module: ruff
2024-08-04 10:36:18.577 [info] Python extension loading
2024-08-04 10:36:18.577 [info] Waiting for interpreter from python extension.
2024-08-04 10:36:18.577 [info] Python extension loaded
2024-08-04 10:36:18.577 [info] Using interpreter: c:\Users\langb\AppData\Local\Programs\Python\Python312\python.exe
2024-08-04 10:36:18.648 [info] Using the Ruff binary: c:\Users\langb\AppData\Local\Programs\Python\Python312\Scripts\ruff.exe
2024-08-04 10:36:18.998 [info] Resolved 'ruff.nativeServer: auto' to use the native server
2024-08-04 10:36:19.000 [info] Found Ruff 0.5.6 at c:\Users\langb\AppData\Local\Programs\Python\Python312\Scripts\ruff.exe
2024-08-04 10:36:19.000 [info] Server run command: c:\Users\langb\AppData\Local\Programs\Python\Python312\Scripts\ruff.exe server
2024-08-04 10:36:19.001 [info] Server: Start requested.
2024-08-04 10:36:19.058 [info] ruff failed
  Cause: workspace URL was not a file path!

Contents of pyproject.toml (in .vscode\extensions\charliermarsh.ruff-2024.36.0-win32-x64)

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "ruff-vscode"
version = "2024.36.0"
description = "A Visual Studio Code extension with support for the Ruff linter."
authors = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }]
maintainers = [{ name = "Charlie Marsh", email = "charlie.r.marsh@gmail.com" }]
requires-python = ">=3.7"
license = "MIT"
dependencies = ["packaging>=23.1", "ruff-lsp==0.0.54", "ruff==0.5.4"]

[project.optional-dependencies]
dev = ["mypy==1.2.0", "python-lsp-jsonrpc==1.0.0"]

[tool.ruff]
line-length = 88
target-version = "py37"
extend-exclude = ["bundled/libs", "scr/testFixture"]

[tool.ruff.lint]
select = ["E", "F", "W", "Q", "UP", "I", "N"]

[tool.mypy]
files = ["bundled/tool", "build", "tests"]
no_implicit_optional = true
check_untyped_defs = true

[[tool.mypy.overrides]]
module = ["debugpy.*", "lsprotocol.*", "pygls.*", "pylsp_jsonrpc.*"]
ignore_missing_imports = true

I've tried python -m pip uninstall ruff and uninstalling the extension, followed by reinstall but this has made no difference.

dhruvmanila commented 1 month ago

Can you turn on verbose logging using the following config and provide the logs? I'm specifically interested in the initialization parameters the client is providing to the editor.

{
    "ruff.trace.server": "verbose"
}

(Assuming that you're using VS Code based on the provided logs)

It's this method (to_file_path) which is failing.

dhruvmanila commented 1 month ago

Also, the pyproject.toml config that you've provided is the one from astral-sh/ruff-vscode extension. Can you provide the path to the folder that's open in VS Code?

Odud commented 1 month ago

Logging output attached.

Regarding your second request I can't find a pyproject.toml (or ruff.toml or .ruff.toml) anywhere in my working directory structure other than the ones I found in astral-sh/ruff-vscode. Please tell me where to look.

Thanks for your help so far.

Pete Barlow

On Mon, 5 Aug 2024 at 04:48, Dhruv Manilawala @.***> wrote:

Can you turn on verbose logging using the following config and provide the logs? I'm specifically interested in the initialization parameters the client is providing to the editor.

{ "ruff.trace.server": "verbose" }

(Assuming that you're using VS Code based on the provided logs)

It's this method (to_file_path https://docs.rs/url/2.5.2/url/struct.Url.html#method.to_file_path) which is failing.

— Reply to this email directly, view it on GitHub https://github.com/astral-sh/ruff/issues/12660#issuecomment-2268116862, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXMVZ5TX35EGIJYF2O6JE3ZP3YYNAVCNFSM6AAAAABL6WGIGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRYGEYTMOBWGI . You are receiving this because you authored the thread.Message ID: @.***>

dhruvmanila commented 1 month ago

Logging output attached.

I'm sorry but I don't see anything attached to your latest message.

Regarding your second request I can't find a pyproject.toml (or ruff.toml or .ruff.toml) anywhere in my working directory structure other than the ones I found in astral-sh/ruff-vscode. Please tell me where to look.

It's fine if there's no config files in your project.

Odud commented 1 month ago

Sorry about that, here it is. I've tried to attach it again.

Pete Barlow

On Mon, 5 Aug 2024 at 11:14, Dhruv Manilawala @.***> wrote:

Logging output attached.

I'm sorry but I don't see anything attached to your latest message.

Regarding your second request I can't find a pyproject.toml (or ruff.toml or .ruff.toml) anywhere in my working directory structure other than the ones I found in astral-sh/ruff-vscode. Please tell me where to look.

It's fine if there's no config files in your project.

— Reply to this email directly, view it on GitHub https://github.com/astral-sh/ruff/issues/12660#issuecomment-2268709667, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXMVZY46B7OQLH7EOSELP3ZP5F6VAVCNFSM6AAAAABL6WGIGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRYG4YDSNRWG4 . You are receiving this because you authored the thread.Message ID: @.***>

dhruvmanila commented 1 month ago

Sorry about that, here it is. I've tried to attach it again.

Unfortunately, I don't see it :(

I'm guessing one can't include attachments when replying to GitHub issue via email.

Odud commented 1 month ago

Trying though github this time, seems to have taken the attachment Ruff.log

Odud commented 1 month ago

So I think I know what is causing it, but not why. At the end of my vscode workspace file I had the following lines

        {
            "name": "Pico (W) Remote Workspace",
            "uri": "pico:"
        }

This was a hangover from when I was doing some Pico development in the same workspace. I've now removed it and restarted Vscode and I haven't seen anymore crashes in Ruff. Ruff is reporting code issues correctly now.

dhruvmanila commented 1 month ago

Yeah, I see the issue. The workspace URI is different than what's expected ("pico:" instead of "file:"). I'm not sure if that's intentional but I wonder if we should ignore the workspace instead of throwing an error and log it as a warning.

dhruvmanila commented 1 month ago

Thanks for providing the logs!

Odud commented 1 month ago

It was included by the Pico extension, it seems to be there to enable looking at the remote Pico filesystem which is accessed over a COM port. My guess would be it is best to ignore rather than error.

Thanks for your help.

Pete Barlow

On Mon, 5 Aug 2024, 13:29 Dhruv Manilawala, @.***> wrote:

Yeah, I see the issue. The workspace URI is different than what's expected ("pico:" instead of "file:"). I'm not sure if that's intentional but I wonder if we should ignore the workspace instead of throwing an error and log it as a warning.

— Reply to this email directly, view it on GitHub https://github.com/astral-sh/ruff/issues/12660#issuecomment-2268957507, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXMVZ4JGSB7DCTLOF2UJWDZP5V2LAVCNFSM6AAAAABL6WGIGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRYHE2TONJQG4 . You are receiving this because you authored the thread.Message ID: @.***>

dhruvmanila commented 1 month ago

My guess would be it is best to ignore rather than error.

Yeah, I agree.

Odud commented 1 month ago

Great! Pete Barlow

On Wed, 7 Aug 2024, 10:16 Dhruv Manilawala, @.***> wrote:

Closed #12660 https://github.com/astral-sh/ruff/issues/12660 as completed via #12725 https://github.com/astral-sh/ruff/pull/12725.

— Reply to this email directly, view it on GitHub https://github.com/astral-sh/ruff/issues/12660#event-13789353260, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXMVZ4MYS3J4BZUBFVLDFLZQHQWFAVCNFSM6AAAAABL6WGIGGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTG44DSMZVGMZDMMA . You are receiving this because you authored the thread.Message ID: @.***>