You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe it concerns a lot of OS errors, when failing they don't print out the path it tried to access.
Describe the solution you'd like
Return the path / variable value in errors where it makes sense
A few examples
They don't all make sense but illustrate the issue:
When using ^ on a variable:
When trying to touch, save or open an impossible path
Of course imagine this as part of a bigger pipeline/loop
> '\P:\x.txt'| touch $in
# Failed to create file: The filename, directory name, or volume label syntax is incorrect. (os error 123)
> '\P:\x.txt'| save $in
# The filename, directory name, or volume label syntax is incorrect. (os error 123)
> '\P:\x.txt'| open $in
# The filename, directory name, or volume label syntax is incorrect. (os error 123)
let module_name = String::from_utf8_lossy(module_name);
let new_name = &[module_name.as_ref(), cmd_name].join(" ");
if engine_state
.find_decl(new_name.as_bytes(),&[])
.is_some()
{
format!("command '{cmd_name}' was not found but it was imported from module '{module_name}'; try using `{new_name}`")
}else{
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}'?")
}
}
}
None => {
if reconfirm_command_name {
format!("executable '{}' was not found",self.name.item)
}else{
"executable was not found".into()
}
}
};
Err(ShellError::ExternalCommand(
label,
err.to_string(),
self.name.span,
))
}
// otherwise, a default error message
_ => Err(ShellError::ExternalCommand(
"can't run executable".into(),
err.to_string(),
self.name.span,
)),
}
}
I was able to hard code it to true and get an error message with a file name but if it's always true then @kubouch's new-ish code doesn't run. I think the synopsis is that we need a refactor around here.
Activity
fdncred commentedon Jan 6, 2023
I tracked this down to always being hard coded to
falseherenushell/crates/nu-command/src/system/run_external.rs
Line 68 in a9bdc65
It comes into play later when creating a label for the error.
nushell/crates/nu-command/src/system/run_external.rs
Lines 292 to 342 in a9bdc65
I was able to hard code it to true and get an error message with a file name but if it's always true then @kubouch's new-ish code doesn't run. I think the synopsis is that we need a refactor around here.
kubouch commentedon Jan 6, 2023
Here is the PR that added the
reconfirm_command_name#6730Refactor I/O Errors (#14927)