Skip to content

cargo fmt failure on Windows, too many command line args #6934

Description

@riverar

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

  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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-fmtArea: cargo-fmtA-ioArea: related to I/O by rustfmt (fs, stdin/stdout, etc.)C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEO-windowsOperating system: Windows

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions