diff --git a/crates/nu-protocol/src/engine/pwd_per_drive.rs b/crates/nu-protocol/src/engine/pwd_per_drive.rs index 9bcef36910..5be71041a3 100644 --- a/crates/nu-protocol/src/engine/pwd_per_drive.rs +++ b/crates/nu-protocol/src/engine/pwd_per_drive.rs @@ -81,14 +81,18 @@ pub mod windows { Ok(path_string) => { if let Some(drive) = extract_drive_letter(&path_string) { maintainer.maintain(env_var_for_drive(drive), value.clone()); + Ok(()) + } else if path_string.is_empty() { + Ok(()) + } else { + // Other path format, like UNC Network share path, or bash format + // /c/Users/nushell will be supported later. + Err(ShellError::InvalidValue { + valid: format!("Can't detect drive letter from {}.", path_string), + actual: path_string, + span: Span::unknown(), + }) } - // Other path format, like UNC Network share path, or bash format - // /c/Users/nushell will be supported later. - Err(ShellError::InvalidValue { - valid: format!("Can't detect drive letter from {}.", path_string), - actual: path_string, - span: Span::unknown(), - }) } Err(e) => Err(ShellError::InvalidValue { valid: "$env.PWD should have String type and String::from_value() should be OK()."