Skip to content

Subcommand aliases silently shadow user-defined aliases #6221

@ordovicia

Description

@ordovicia

Problem
Users can define aliases in ~/.cargo/config.
But user-defined b, r, and t aliases do not work because they are shadowed by subcommand aliases (resp. for build, run, and test).
Cargo does not emit any warnings.

Steps

  1. Add the following definition to ~/.cargo/config
[alias]
b = "foo"
  1. Run cargo b
  2. Cargo executes build subcommand, not foo, without any warnings

Notes

  • Current Cargo warns user-defined aliases shadowed by (non-alias) subcommands here:

    cargo/src/bin/cargo/cli.rs

    Lines 121 to 126 in efb7972

    (Some(_), Some(_)) => {
    config.shell().warn(format!(
    "alias `{}` is ignored, because it is shadowed by a built in command",
    cmd
    ))?;
    }
  • I sent a PR that adds c alias for check (Add c alias for check #6218), which will shadow user-defined c aliases.
  • Documenting subcommand aliases would tell people not to define such aliases (Aliases entirely undocumented #4391).

Output of cargo version:
cargo 1.29.0 (524a578d7 2018-08-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions