Skip to content

ruff server appears to resolve configuration files differently to ruff check #20847

@lewis6991

Description

@lewis6991

Summary

I have a project with this structure:

├── pyproject.toml
└── sub/
    ├── main.py
    └── pyproject.toml

ruff server seems to always use the pyproject.toml defined in the root, even if ruff server is called with cwd set to sub. This is inconsistent with ruff check.

Reproduction steps:

mkdir ruff_issue
cd ruff_issue
git init
echo '[tool.ruff]\nexclude=["sub"]' > pyproject.toml
mkdir sub
touch sub/pyproject.toml
echo 'print "Hello world!"' > sub/main.py

git add \
    pyproject.toml
    sub/pyproject.toml \
    sub/main.py

git commit -m "Initial commit"

ruff check # uses root pyproject.toml, reports no issues, expected
# ruff server with cwd set to root, reports no issues, expected

cd sub

ruff check # uses sub/pyproject.toml, reports issues, expected
# ruff server with cwd set to sub, reports no issues, NOT EXPECTED

I don't know how to get diagnostics from ruff server without using an editor. I'm currently using Neovim with the default config defined in https://github.com/neovim/nvim-lspconfig which simply calls ruff server in the directory of the closest pyproject.toml in a bottom-up search.

Version

ruff 0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-infoMore information is needed from the issue authorserverRelated to the LSP server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions