{"id":"aa7fa06b542b91f6","repo":"rust-lang/cargo","slug":"subcommand-is-required-but-alias-name-is-empt","errorCode":null,"errorMessage":"subcommand is required, but `{alias_name}` is empty","messagePattern":"subcommand is required, but `(.+?)` is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bin/cargo/main.rs","lineNumber":159,"sourceCode":"            record\n                .val\n                .split_whitespace()\n                .map(|s| s.to_string())\n                .collect(),\n        ),\n        Ok(None) => None,\n        Err(_) => gctx.get::<Option<Vec<String>>>(&alias_name)?,\n    };\n\n    let result = user_alias.or_else(|| {\n        builtin_aliases_execs(command).map(|command_str| vec![command_str.1.to_string()])\n    });\n    if result\n        .as_ref()\n        .map(|alias| alias.is_empty())\n        .unwrap_or_default()\n    {\n        anyhow::bail!(\"subcommand is required, but `{alias_name}` is empty\");\n    }\n    Ok(result)\n}\n\n/// List all runnable commands\nfn list_commands(gctx: &GlobalContext) -> BTreeMap<String, CommandInfo> {\n    let mut commands = third_party_subcommands(gctx);\n\n    for cmd in commands::builtin() {\n        commands.insert(\n            cmd.get_name().to_string(),\n            CommandInfo::BuiltIn {\n                about: cmd.get_about().map(|s| s.to_string()),\n            },\n        );\n    }\n\n    // Add the builtin_aliases and them descriptions to the","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/bin/cargo/main.rs#L141-L177","documentation":"In aliased_command (main.rs:154-160), Cargo resolves a `cargo <command>` alias from config (`alias.<command>`). If the resolved alias value is an empty list/string, the alias points nowhere, so Cargo cannot determine which subcommand to run and bails.","triggerScenarios":"Defining `[alias] foo = \"\"` or `foo = []` in `.cargo/config.toml` and then running `cargo foo`. Also triggered by a builtin alias that resolves empty.","commonSituations":"Misconfigured `~/.cargo/config.toml` or `.cargo/config.toml` with an empty alias; environment-variable expansion producing empty; copy-pasted config with a placeholder that was never filled in.","solutions":["Edit `.cargo/config.toml` (or `~/.cargo/config.toml`) and give the alias a real command, e.g. `[alias]\\nt = \"test\"`.","Remove the empty alias entry if it is unused.","Run `cargo config get` (or inspect the file) to confirm the alias value."],"exampleFix":"// before (.cargo/config.toml)\n[alias]\nr = \"\"\n\n// after\n[alias]\nr = \"run\"","handlingStrategy":"validation","validationCode":"// Validate config alias before relying on it\nlet alias = gctx.get_string(&format!(\"alias.{cmd}\"))?;\nif let Some(rec) = alias {\n    if rec.val.trim().is_empty() {\n        return Err(format!(\"alias.{cmd} is empty; set a real command\"));\n    }\n}","typeGuard":"fn alias_is_valid(v: &str) -> bool {\n    !v.trim().is_empty()\n}\n","tryCatchPattern":null,"preventionTips":["Lint `.cargo/config.toml` aliases in CI (toml parse + non-empty check).","Avoid placeholder aliases; remove entries you do not use."],"tags":["cargo","alias","config","cli"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}