rustfmt's `--config-path` help text is misleading
Open
Nobody has claimed this yet.
A-config
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
As of 8b0b213cddb23a9bbe421b717d1a0e5fb3982712, the help text is:
$ rustfmt -h
...
--config-path [Path for the configuration file]
Recursively searches the given path for the
rustfmt.toml config file. If not found reverts to the
input file path
Some points of confusion:
- How can there be a recursive search if the configure is a "file":
[Path for the configuration file]?
a. It seems like this option can take a directory withrustfmt.tomlOR the file itself. - When passed a directory,
rustfmtdoes not appear to search recursively for a config file through ancestors or decedent directories:$ mkdir -p /tmp/dir1/dir2/dir3 $ find /tmp/dir1/ /tmp/dir1/ /tmp/dir1/dir2 /tmp/dir1/dir2/dir3 $ strace target/debug/rustfmt --config-path=/tmp/dir1/dir2/ /dev/null |& rg dir1 -C1 execve("target/debug/rustfmt", ["target/debug/rustfmt", "--config-path=/tmp/dir1/dir2/", "/dev/null"], 0x7ffc4c2ad340 /* 61 vars */) = 0 brk(NULL) = 0x5607c5058000 -- statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "/tmp/dir1/dir2/", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|0x1000, stx_attributes=0, stx_mode=S_IFDIR|0775, stx_size=4096, ...}) = 0 statx(AT_FDCWD, "/tmp/dir1/dir2/", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|0x1000, stx_attributes=0, stx_mode=S_IFDIR|0775, stx_size=4096, ...}) = 0 statx(AT_FDCWD, "/tmp/dir1/dir2/.rustfmt.toml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc9118d8b0) = -1 ENOENT (No such file or directory) statx(AT_FDCWD, "/tmp/dir1/dir2/rustfmt.toml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc9118d8b0) = -1 ENOENT (No such file or directory) write(2, "Error: unable to find a config f"..., 73Error: unable to find a config file for the given path: `/tmp/dir1/dir2/`) = 73 write(2, "\n", 1 - The last sentence says that if the file is not found, then "reverts to the input file path", but it seems like
rustfmtwill emit an error when the file does not existrustfmt --config-path=/does/not/exist /dev/null Error: unable to find a config file for the given path: `/does/not/exist`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the rustfmt CLI definition and the help text for --config-path, then reproduce the documented directory, file, and nonexistent-path commands from the issue. Done means the help text accurately describes accepted paths, search behavior, and the error case, with checks covering the reported examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100