Skip to content

Cargo aliases fail inside nested worktrees because config arrays merge by concatenation #1003

Description

@aram356

Symptom

Running any workspace alias inside a git worktree nested under the repo root (e.g. .claude/worktrees/<name>) fails:

$ cargo check-fastly
error: unexpected argument 'check' found

Every alias is affected (check-fastly, test-axum, clippy-cloudflare, ...).

Root cause

Cargo discovers .cargo/config.toml in the current directory and every ancestor directory. A worktree nested inside the repo therefore loads the file twice: the worktree's own checked-out copy and the parent checkout's copy.

Per Cargo's config-merge rules, array values are merged by concatenation, so each alias expands to doubled tokens (check -p ... check -p ...), which fails argument parsing. String values are instead overridden by the deeper config.

Fix

Convert the aliases in .cargo/config.toml from array form to string form. Cargo splits string aliases on whitespace, so behavior at the repo root is identical, and nested worktrees resolve to a single definition.

Note: string and array forms do not coexist across the nesting - a mixed pair fails with error: could not load Cargo configuration. Nested worktrees work once both the parent checkout's branch and the worktree's branch carry the fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions