From 7616429436c8799bfc0c04287712814423485458 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 13 Jan 2025 22:29:21 -0500 Subject: [PATCH] fix(compile/windows): better handling of deno_dir on different drive letter than code (#27654) Closes https://github.com/denoland/deno/issues/27651 --- cli/standalone/binary.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 296d6825a7..ff0343e27f 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -1007,8 +1007,16 @@ impl<'a> DenoCompileBinaryWriter<'a> { // this is not as optimized as it could be let mut last_name = Cow::Borrowed(DENO_COMPILE_GLOBAL_NODE_MODULES_DIR_NAME); - for ancestor in parent.ancestors() { - let dir = vfs.get_dir_mut(ancestor).unwrap(); + for ancestor in + parent.ancestors().map(Some).chain(std::iter::once(None)) + { + let dir = if let Some(ancestor) = ancestor { + vfs.get_dir_mut(ancestor).unwrap() + } else if cfg!(windows) { + vfs.get_system_root_dir_mut() + } else { + break; + }; if let Ok(index) = dir.entries.binary_search(&last_name, case_sensitivity) {