Skip to content

Server: Consider root_uri/root_path as a fallback to detect workspace root #19200

@lunik1

Description

@lunik1

Summary

When running the ruff LSP server via ruff server I am not seeing diagnostics I have enabled using a pyproject.toml in a subdirectory. I do see the correct diagnostics when running ruff check or the standalone ruff-lsp.

I have a mwe of this bug here: https://github.com/lunik1/ruff-server-bug-mwe

The top-level pyproject.toml contains a basic ruff configuration:

[tool.ruff]
target-version = "py311"

[tool.ruff.lint]

which is then extended by ruff-mwe/pyproject.toml to enable the RUF linting rules

[tool.ruff]
extend = "../pyproject.toml"

[tool.ruff.lint]
extend-select = ["RUF"]

main.py contains some code that violates F401 (a default rule) and RUF005

import math

def main():
    foo = [2, 3, 4]
    bar = [1] + foo + [5, 6]

    print(bar)

which is correctly detected by ruff check

ruff-mwe/main.py:1:8: F401 [*] `math` imported but unused
  |
1 | import math
  |        ^^^^ F401
2 |
3 | def main():
  |
  = help: Remove unused import: `math`

ruff-mwe/main.py:5:11: RUF005 Consider `[1, *foo, 5, 6]` instead of concatenation
  |
3 | def main():
4 |     foo = [2, 3, 4]
5 |     bar = [1] + foo + [5, 6]
  |           ^^^^^^^^^^^^^^^^^^ RUF005
6 |
7 |     print(bar)
  |
  = help: Replace with `[1, *foo, 5, 6]`

Found 2 errors.
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).

however, only the F401 is displayed in my editor (emacs + lsp-mode) using ruff server

Image

If I switch my server command to be ruff-lsp, I see both diagnostics:

Image

Version

ruff 0.12.2 (9bee837 2025-07-03)

Metadata

Metadata

Assignees

No one assigned

    Labels

    serverRelated to the LSP server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions