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: #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-a1326fb90c2c on a Windows machine.
cd repro-a1326fb90c2c
cargo fmt
- Observe error
Meta
rustfmt --version:
rustfmt 1.9.0-nightly (cced03bfd6 2026-05-28)
Summary
cargo fmtfails withThe 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: #5975
Expected behavior
cargo fmtto format all code as it does with smaller cratesActual 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 fmtMeta
rustfmt --version: