Skip to content

Conversation

@tmfink
Copy link
Contributor

@tmfink tmfink commented Aug 4, 2025

Users may have files where directories are expected, such as $HOME/.config being a file when trying to lookup $HOME/.config/rustfmt/.rustfmt.toml. We don't want to treat such situations as errors.

$ rustfmt src/main.rs Failed to get metadata for config file "/tmp/fake-home/.config/rustfmt/.rustfmt.toml": Not a directory (os error 20) 

To reproduce the situation on a Unix-like system:

# make fake home dir mkdir /tmp/fake-home touch /tmp/fake-home/.config # make test rust project cd /tmp/ cargo new hello # try to format ## use the path to a real rustfmt executable, not rustup HOME=/tmp/fake-home /path/to/rustfmt /tmp/hello/src/main.rs
@fee1-dead
Copy link
Member

Do you think we could have a test at https://github.com/rust-lang/rustfmt/blob/master/tests/rustfmt/main.rs, or some other place?

Users may have files where directories are expected, such as "$HOME/.config" being a file when trying to lookup "$HOME/.config/rustfmt/.rustfmt.toml". We don't want to treat such situations as errors.
@tmfink
Copy link
Contributor Author

tmfink commented Oct 18, 2025

@fee1-dead I added the test. To get a proper test (that failed before my change) I needed to use the OS temp directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants