-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Read user configuration from ~/.config/ruff/ruff.toml
on macOS
#11115
Conversation
a663349
to
72b3e76
Compare
72b3e76
to
a1f871d
Compare
@@ -34,6 +34,7 @@ crossbeam = { version = "0.8.4" } | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <micha@reiser.io> Closes #10739.
) Co-authored-by: Micha Reiser <micha@reiser.io> Closes #10739.
Summary
This PR moves Ruff's user-specific configuration from
~/Library/Application Support/ruff/ruff.toml
to~/.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
.