{"id":"08e1b05ea9eceafd","repo":"rust-lang/cargo","slug":"no-such-subcommand-cmd-suggested-command-sugg","errorCode":null,"errorMessage":"no such subcommand `{cmd}`{suggested_command}{suggested_script}","messagePattern":"no such subcommand `(.+?)`(.+?)(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bin/cargo/commands/run.rs","lineNumber":172,"sourceCode":"                    format!(\n                        \" {}\",\n                        args.into_iter().map(|os| os.to_string_lossy()).join(\" \")\n                    )\n                };\n                format!(\n                    \"\\nhelp: there is a command with a similar name: `{suggested_command} {actual_args}{args}`\"\n                )\n            } else {\n                \"\".to_owned()\n            };\n            let suggested_script = if let Some(suggested_script) = suggested_script(cmd) {\n                format!(\n                    \"\\nhelp: there is a script with a similar name: `{suggested_script}` (requires `-Zscript`)\"\n                )\n            } else {\n                \"\".to_owned()\n            };\n            return Err(anyhow::anyhow!(\n                \"no such subcommand `{cmd}`{suggested_command}{suggested_script}\"\n            )\n            .into());\n        }\n    }\n\n    let manifest_path = root_manifest(Some(manifest_path), gctx)?;\n\n    // Treat `cargo foo.rs` like `cargo install --path foo` and re-evaluate the config based on the\n    // location where the script resides, rather than the environment from where it's being run.\n    let parent_path = manifest_path\n        .parent()\n        .expect(\"a file should always have a parent\");\n    gctx.reload_rooted_at(parent_path)?;\n\n    let mut ws = Workspace::new(&manifest_path, gctx)?;\n    if gctx.cli_unstable().avoid_dev_deps {\n        ws.set_require_optional_deps(false);","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/bin/cargo/commands/run.rs#L154-L190","documentation":"Raised in the (false, false) arm of exec_manifest_command (run.rs:141-176): the token is neither an existing file nor usable as a script, and script support is off. Cargo could not find a matching built-in or third-party subcommand, so it reports `no such subcommand` with optional suggestions for close command names or scripts that require `-Zscript`.","triggerScenarios":"Running `cargo foobar` where `foobar` is not a built-in command, not a `cargo-foobar` executable on PATH, not an existing file, and `-Zscript` is not enabled.","commonSituations":"Typos in subcommand names; expecting a third-party subcommand that isn't installed; using a nightly-only subcommand on stable; stale muscle memory after a subcommand was renamed.","solutions":["Check spelling against `cargo --list`.","Install the intended external command: `cargo install cargo-<name>`.","If the suggestion mentions a script, run on nightly with `-Zscript`.","If you meant to run a file, ensure the path exists and pass `-Zscript`."],"exampleFix":"// before\n$ cargo bulid\nerror: no such subcommand `bulid`\nhelp: there is a command with a similar name: `build`\n\n// after\n$ cargo build","handlingStrategy":"validation","validationCode":"// Validate the subcommand before exec'ing cargo\nlet known = list_builtin_commands().iter().any(|c| c == cmd)\n    || third_party_installed(cmd)      // cargo-<cmd> on PATH\n    || Path::new(cmd).is_file();\nif !known {\n    eprintln!(\"unknown cargo subcommand `{cmd}`; check `cargo --list`\");\n}","typeGuard":"fn looks_like_valid_cargo_cmd(cmd: &str, installed: &[String]) -> bool {\n    let is_builtin = matches!(cmd, \"build\"|\"run\"|\"test\"|\"check\"|\"doc\"|\"tree\"|\"update\"|/* ... */);\n    is_builtin || installed.iter().any(|c| c == cmd)\n}\n","tryCatchPattern":null,"preventionTips":["Run `cargo --list` to confirm available subcommands.","Install expected cargo-<cmd> extensions in CI before invoking them.","Unit-test CLI argument spelling before shelling out."],"tags":["cargo","cli","subcommand","typo"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}