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?

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

@fee1-dead
Copy link
Member

This LGTM, although conflicts might need to be resolved.

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 Jan 1, 2026

I rebased & resolved conflicts.

@fee1-dead fee1-dead merged commit 3f7e9cc into rust-lang:main Jan 2, 2026
26 checks passed
@ytmimi ytmimi added the release-notes Needs an associated changelog entry label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes Needs an associated changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants