`cargo fmt` failure on Windows, too many command line args
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Summary
cargo fmt fails with The filename or extension is too long. (os error 206) when the workspace contains a deep hierarchy, many files, and/or many crates resulting in a rustfmt command line length that exceeds ~32K.
We are currently hitting this in https://github.com/microsoft/windows-rs. (I have a smaller repro below.)
Related: https://github.com/rust-lang/rustfmt/issues/5975
Expected behavior
cargo fmt to format all code as it does with smaller crates
Actual behavior
The filename or extension is too long. (os error 206)
Configuration
N/A
Reproduction Steps
git clone https://github.com/riverar/repro-a1326fb90c2con a Windows machine.cd repro-a1326fb90c2ccargo fmt- Observe error
Meta
rustfmt --version:
rustfmt 1.9.0-nightly (cced03bfd6 2026-05-28)
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 reproducing the failure with cargo fmt on Windows using the linked repro repository, then trace the cargo fmt entry point and how it handles large workspaces. Done means formatting succeeds for the provided deep, multi-crate workspace without hitting Windows error 206, while smaller workspaces continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100