Skip to content

Allow NotADirectory errors in config lookup #6624

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

2 participants