From 6e1f3aa0131f145db631d5dfb94c2b9404172194 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 13 Nov 2023 09:44:01 -0500 Subject: fix(install): should work with non-existent relative root (#21161) Closes #21160 --- cli/util/fs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cli/util') diff --git a/cli/util/fs.rs b/cli/util/fs.rs index c1fd00f5e..33eb3af9d 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -206,8 +206,14 @@ pub fn canonicalize_path_maybe_not_exists_with_fs( return Ok(canonicalized_path); } Err(err) if err.kind() == ErrorKind::NotFound => { - names_stack.push(path.file_name().unwrap()); - path = path.parent().unwrap(); + names_stack.push(match path.file_name() { + Some(name) => name.to_owned(), + None => return Err(err), + }); + path = match path.parent() { + Some(parent) => parent, + None => return Err(err), + }; } Err(err) => return Err(err), } -- cgit v1.2.3