From 16e061f691bdbe9b6852a8d8a12fce2fc0eaae8b Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Thu, 15 Jan 2026 14:23:32 -0800 Subject: [PATCH 1/2] Enhance symlink handling in create_unknown_env for Windows compatibility --- crates/pet/src/locators.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/pet/src/locators.rs b/crates/pet/src/locators.rs index c51302d2..b91449ca 100644 --- a/crates/pet/src/locators.rs +++ b/crates/pet/src/locators.rs @@ -165,10 +165,23 @@ fn create_unknown_env( resolved_env: ResolvedPythonEnv, fallback_category: Option, ) -> PythonEnvironment { - // Find all the python exes in the same bin directory. + // Combine symlinks from resolved_env (which includes the original executable path + // and the resolved path) with any additional symlinks found in the bin directory. + // This is important on Windows where scoop and similar tools use shim executables + // that redirect to the real Python installation. + let mut symlinks = resolved_env.symlinks.clone().unwrap_or_default(); + if let Some(additional_symlinks) = find_symlinks(&resolved_env.executable) { + for symlink in additional_symlinks { + if !symlinks.contains(&symlink) { + symlinks.push(symlink); + } + } + } + symlinks.sort(); + symlinks.dedup(); PythonEnvironmentBuilder::new(fallback_category) - .symlinks(find_symlinks(&resolved_env.executable)) + .symlinks(Some(symlinks)) .executable(Some(resolved_env.executable)) .prefix(Some(resolved_env.prefix)) .arch(Some(if resolved_env.is64_bit { From d7f2cd82de9ff4025115d2e8c0fc7a8625caed00 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Fri, 16 Jan 2026 13:08:21 -0800 Subject: [PATCH 2/2] Simplify symlink handling in create_unknown_env by using extend method --- crates/pet/src/locators.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/pet/src/locators.rs b/crates/pet/src/locators.rs index b91449ca..a1c32cad 100644 --- a/crates/pet/src/locators.rs +++ b/crates/pet/src/locators.rs @@ -171,11 +171,7 @@ fn create_unknown_env( // that redirect to the real Python installation. let mut symlinks = resolved_env.symlinks.clone().unwrap_or_default(); if let Some(additional_symlinks) = find_symlinks(&resolved_env.executable) { - for symlink in additional_symlinks { - if !symlinks.contains(&symlink) { - symlinks.push(symlink); - } - } + symlinks.extend(additional_symlinks); } symlinks.sort(); symlinks.dedup();