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 extension can't find the pyproject.toml config when reading some files and not others #713

Open
Zeddicus414 opened this issue Mar 6, 2025 · 3 comments
Labels
needs-info More information is needed from the issue author

Comments

@Zeddicus414
Copy link

Zeddicus414 commented Mar 6, 2025

Hey all,

Thank you for maintaining the VSCode ruff extension. I love using ruff in my editor!

However, I've got a problem that I just can't figure out for the life of me...
The Ruff LSP throws 2025-03-06 16:02:55.146835200 WARN No settings available for file:///c%3A/Source/.../database_access.py - falling back to default settings for some files and not others in my project. Sometimes the files that work and don't work change. I'm not sure why.

My project has a pyproject.toml at the top level folder. If I run uv run ruff format . it works perfectly.

VSCode info:

Version: 1.98.0 (user setup)
Commit: 6609ac3d66f4eade5cf376d1cb76f13985724bcb
Date: 2025-03-04T21:06:18.612Z
Electron: 34.2.0
ElectronBuildId: 11044223
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.22631

Extension Installation:

Identifier charliermarsh.ruff
Version 2025.14.0
Last Updated 2025-02-28, 10:37:45
Size 35.65MB

Ruff settings:

  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.formatOnSave": true,
  },
  "ruff.configurationPreference": "filesystemFirst",
  "ruff.logFile": "c:/source/.../ruff.log",
  "ruff.logLevel": "debug",
  "ruff.importStrategy": "useBundled",

In the case of this log file, I literally have two files open in VSCode,
Image
data_structures.py formats as I would expect and matches the CLI. etl_database_access.py formats with the default config and makes hundreds of changes.

I did change the project name in this log file, since it's work proprietary:
my_ruff.log

Any help or guidance would be greatly appreciated! Thank you so much for making something so cool and helpful for the python community.

@Zeddicus414 Zeddicus414 changed the title Ruff Extension randomly can't find the pyproject.toml config when reading some files and not others Ruff extension can't find the pyproject.toml config when reading some files and not others Mar 6, 2025
@MichaReiser
Copy link
Member

Thanks for the kind words and the detailed write up.

I believe the relevant lines in the log are:

2025-03-06 16:41:06.086695000 DEBUG Indexing settings for workspace: c:\source\PROJECTNAME
2025-03-06 16:41:06.098413500 DEBUG Ignored path via `exclude`: c:\source\PROJECTNAME\.git
2025-03-06 16:41:06.104849700 DEBUG Ignored path via `exclude`: c:\source\PROJECTNAME\.ruff_cache
2025-03-06 16:41:06.117166100  INFO Registering workspace: c:\source\PROJECTNAME
2025-03-06 16:41:06.177908300  WARN No settings available for file:///c%3A/Source/PROJECTNAME/etl/database/etl_database_access.py - falling back to default settings

Note how the workspace uses source in lowercase, whereas the warning message uses Source in uppercase. Can you tell me what the casing of C:\source is on disk? Is it C:\source or C:\Source? I'm not sure why VS code gives us once one path and than the other but I suspect that we may have to do some normalization on our end or change the setting lookup to be case-insensitive on case-insensitive file systems (windows, macos)

@dhruvmanila
Copy link
Member

Another difference is that I think the path with lowercase source is a PathBuf while the one in uppercase Source is a Url. We do use the file path to get the settings: https://github.com/astral-sh/ruff/blob/d94a78a134c438c063d144e11f2ae8c1657dfa99/crates/ruff_server/src/session/index.rs#L211-L213.

@dhruvmanila dhruvmanila added the needs-info More information is needed from the issue author label Mar 7, 2025
@Zeddicus414
Copy link
Author

Zeddicus414 commented Mar 7, 2025

The directory is uppercase C:\Source

Everything else in the path is lowercase, including the project name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info More information is needed from the issue author
Projects
None yet
Development

No branches or pull requests

3 participants