Read user configuration from ~/.config/ruff/ruff.toml on macOS#11115
Read user configuration from ~/.config/ruff/ruff.toml on macOS#11115MichaReiser merged 4 commits intoruff-0.5from
~/.config/ruff/ruff.toml on macOS#11115Conversation
a663349 to
72b3e76
Compare
72b3e76 to
a1f871d
Compare
| dirs = { version = "5.0.0" } | ||
| drop_bomb = { version = "0.1.5" } | ||
| env_logger = { version = "0.11.0" } | ||
| etcetera = { version = "0.8.0" } |
There was a problem hiding this comment.
@konstin suggested this crate, and it does what we want across Windows and Linux / macOS, but open to other suggestions.
Cargo.toml
Outdated
| @@ -34,6 +34,7 @@ crossbeam = { version = "0.8.4" } | |||
| dirs = { version = "5.0.0" } | |||
There was a problem hiding this comment.
We can remove dirs in a future release, but it stays around for now for backwards compatibility.
|
|
Sooo, we're doing twitter driven development now 😂 |
|
I would change the reasoning/description: Follow the XDG specification on all Unix platforms. Ruff will now use the XDG config directory to read user-level configuration (default: |
| return Some(path); | ||
| // On macOS, we used to support reading from `/Users/Alice/Library/Application Support`. | ||
| if cfg!(target_os = "macos") { | ||
| let deprecated_config_dir = dirs::config_dir()?.join("ruff"); |
There was a problem hiding this comment.
Could we use https://docs.rs/etcetera/latest/etcetera/app_strategy/struct.Apple.html here and remove the dirs dependency (trading one dependency for another ;))
There was a problem hiding this comment.
Okay I checked, we can use the Apple strategy but we need to use the data_dir to map to the Application Support folder (hardcoded).
The etcetera crate clearly documents that config_dir shouldn't be used on Mac when the config is user editable. I'm going to make this change.
From the dirs documentation:
// Mac: Some(/Users/Alice/Library/Application Support)
dirs::config_dir();
From the etcetera documentation:
assert_eq!(
base_strategy.data_dir().strip_prefix(&home_dir),
Ok(Path::new("Library/Application Support/"))
);There was a problem hiding this comment.
Interesting. Feel free to merge.
CodSpeed Performance ReportMerging #11115 will degrade performances by 4.69%Comparing Summary
Benchmarks breakdown
|
|
I ran through the test plan and verified the deprecation message. |
) Co-authored-by: Micha Reiser <[email protected]> Closes #10739.
) Co-authored-by: Micha Reiser <[email protected]> Closes #10739.
Summary
This PR moves Ruff's user-specific configuration from
~/Library/Application Support/ruff/ruff.tomlto~/.config/ruff/ruff.toml.Many other tools do this. On my machine alone: dagger, zed, gatsby, gh, wandb, etc.
I also polled Twitter and it won in a landslide:
Let's ship this in v0.5.0, along with a deprecation warning (so we'll continue to respect
~/Library/Application Support/ruff/ruff.toml, but log a warning).Closes #10739.
Test Plan
cargo check foo.py.~/.config/ruff/ruff.toml.