Skip to content

Commit 4b67cdd

Browse files
authored
Enhance symlink handling in create_unknown_env for Windows compatibility (#280)
For 187
1 parent 9d5a308 commit 4b67cdd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/pet/src/locators.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,19 @@ fn create_unknown_env(
165165
resolved_env: ResolvedPythonEnv,
166166
fallback_category: Option<PythonEnvironmentKind>,
167167
) -> PythonEnvironment {
168-
// Find all the python exes in the same bin directory.
168+
// Combine symlinks from resolved_env (which includes the original executable path
169+
// and the resolved path) with any additional symlinks found in the bin directory.
170+
// This is important on Windows where scoop and similar tools use shim executables
171+
// that redirect to the real Python installation.
172+
let mut symlinks = resolved_env.symlinks.clone().unwrap_or_default();
173+
if let Some(additional_symlinks) = find_symlinks(&resolved_env.executable) {
174+
symlinks.extend(additional_symlinks);
175+
}
176+
symlinks.sort();
177+
symlinks.dedup();
169178

170179
PythonEnvironmentBuilder::new(fallback_category)
171-
.symlinks(find_symlinks(&resolved_env.executable))
180+
.symlinks(Some(symlinks))
172181
.executable(Some(resolved_env.executable))
173182
.prefix(Some(resolved_env.prefix))
174183
.arch(Some(if resolved_env.is64_bit {

0 commit comments

Comments
 (0)