Skip to content

Commit 2ac8f88

Browse files
committed
fix: canonicalize virtual environment directory for accurate comparison on Windows
1 parent b35e3e4 commit 2ac8f88

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/pet/src/find.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,21 @@ mod tests {
725725

726726
let environments = reporter.environments.lock().unwrap();
727727

728+
// Canonicalize the venv_dir for comparison (handles Windows 8.3 short paths)
729+
let venv_dir_canonical = fs::canonicalize(&venv_dir).unwrap_or(venv_dir.clone());
730+
728731
// The venv should be discovered even when searching by kind
732+
// Use canonicalize to handle Windows short path names (e.g., RUNNER~1 vs runneradmin)
729733
let venv_found = environments.iter().any(|env| {
730734
env.kind == Some(PythonEnvironmentKind::Venv)
731-
&& env.prefix.as_ref().map(|p| p == &venv_dir).unwrap_or(false)
735+
&& env
736+
.prefix
737+
.as_ref()
738+
.map(|p| {
739+
let p_canonical = fs::canonicalize(p).unwrap_or(p.clone());
740+
p_canonical == venv_dir_canonical
741+
})
742+
.unwrap_or(false)
732743
});
733744

734745
assert!(

0 commit comments

Comments
 (0)