rust-lang / rust-lang/rustfmt

`cargo fmt` failure on Windows, too many command line args

Open
#6,934 25 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-cargo-fmt A-io C-bug O-windows
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

  1. git clone https://github.com/riverar/repro-a1326fb90c2c on a Windows machine.
  2. cd repro-a1326fb90c2c
  3. cargo fmt
  4. Observe error

Meta

rustfmt --version:

rustfmt 1.9.0-nightly (cced03bfd6 2026-05-28)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.