diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index ebda1e3446..68c4299667 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -312,7 +312,12 @@ impl ExternalCommand { format!("command '{cmd_name}' was not found but it exists in module '{module_name}'; try importing it with `use`") } } else { - format!("did you mean '{s}'?") + // If command and suggestion are the same, display not found + if cmd_name == &s { + format!("'{cmd_name}' was not found") + } else { + format!("did you mean '{s}'?") + } } } } diff --git a/tests/shell/pipeline/commands/external.rs b/tests/shell/pipeline/commands/external.rs index 2ae5dc67ba..caddb15760 100644 --- a/tests/shell/pipeline/commands/external.rs +++ b/tests/shell/pipeline/commands/external.rs @@ -128,6 +128,18 @@ fn command_not_found_error_suggests_typo_fix() { assert!(actual.err.contains("timeit")); } +#[test] +fn command_not_found_error_shows_not_found() { + let actual = nu!( + cwd: ".", + r#" + export extern "foo" []; + foo + "# + ); + assert!(actual.err.contains("'foo' was not found")); +} + #[test] fn command_substitution_wont_output_extra_newline() { let actual = nu!(