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

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.
@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?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants