rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.01k stars 883 forks source link

`imports_granularity` not working on global config file #5471

Open laralove143 opened 2 years ago

laralove143 commented 2 years ago

this is very weird, if my config file is at /Users/lara/Library/Preferences/rustfmt/rustfmt.toml the options are detected (cargo fmt complains it can't set the options on stable), but they don't do anything.. i'm not sure if only imports_granularity is affected

putting the file at /Users/lara/rustfmt.toml or next to Cargo.toml makes it work fine

rustfmt version is rustfmt 1.5.1-nightly (4d6d601c 2022-07-26)

ytmimi commented 2 years ago

I believe this might be a duplicate of #4613

ytmimi commented 2 years ago

I think the issue is that the Configurations.md is pointing to dirs v1.0.4, but we've since upgraded to dirs v4.0.0. Can you try placing the global config in $HOME/Library/Application Support like the v4.0.0 docs suggest and see if that resolves the issue.

ytmimi commented 2 years ago

For anyone wanting to work on this we just need to update the link in the first paragraph of the Configurations.md to point at the same version as listed in the Cargo.toml

ytmimi commented 2 years ago

For what it's worth this was the PR that bumped the version #5237

aizpurua23a commented 2 years ago

Hey! Consider this PR :)

ytmimi commented 2 years ago

@aizpurua23a thanks for the PR! @laralove143 when you have a moment please confirm that placing your config in $HOME/Library/Application Support resolves the issue.

laralove143 commented 2 years ago

it doesn't seem to detect the config, its at /Users/lara/Library/Application Support/rustfmt/rustfmt.toml there are nightly options but cargo fmt doesn't complain about anything

calebcartwright commented 2 years ago

Can you try running with the --verbose flags? That should tell you which config file, if any, is getting picked up. Remember that rustfmt doesn't (currently) support aggregated configs, so it will just pick up the first one it finds on the probe path. That means that if you have one locally in your project, a parent directory, etc. those will get selected and rustfmt won't look in home directory