vscode-ruff
vscode-ruff copied to clipboard
Ruff extension can't find the pyproject.toml config when reading some files and not others
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,
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.
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)
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.
The directory is uppercase C:\Source
Everything else in the path is lowercase, including the project name.
Hi @MichaReiser and @dhruvmanila, this issue is still tagged as "Needs info", but to the best of my knowledge, I have provided the information that you requested. Is there anything else that I can provide?
Looking at the logs again it seems that the settings don't work for paths starting with file:///c%3A/Source/ instead of c:\ but I don't know why the paths are different. You aren't using WSL or a remote server by chance?
I opened vscode from Git Bash with the command code ., but I am not doing any work in WSL or a remote server from inside VScode. In my terminal, I'm using podman, which relies on WSL.
A couple other potential pieces of puzzle:
- as far as I can tell, things work correctly if I rename from 'Source' to 'source'
- I must be have something opening WSL in a way that I didn't expect because File Locksmith on
c:\Sourcehaswslhost.exeandwin-sshproxy.exelisted.
I have this in my .bashrc:
cd C:\source\PROJECTDIR || exit
podman machine start
It's the podman command executing from this folder that is holding the WSLhost.exe open. Maybe there is some crazy interaction between this and ruff language server/ruff? I can make Source lowercase and call this issue closed if you would like. It does seem likely that I might have done something wrong somewhere.