Skip to content

Commit e7c9282

Browse files
committed
Fix parent-relative virtual dirs misclassification in hatch_env
Normalize env_dir path before checking if it's inside the project. Previously, parent-relative paths like ../envs would incorrectly be classified as in-project because Path::starts_with treats '..' as a regular component. Now we canonicalize the path first, which resolves '..' correctly before the starts_with check.
1 parent 33e3a1c commit e7c9282

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎crates/socket-patch-core/src/crawlers/hatch_env.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ pub(crate) async fn hatch_environments_with(
119119
let Some(env_dir) = virtual_env_dir(&root, config.as_ref(), var) else {
120120
return found;
121121
};
122-
let in_project = env_dir.starts_with(&root)
123-
|| std::fs::canonicalize(&env_dir).is_ok_and(|d| d.starts_with(&root));
122+
let env_dir = std::fs::canonicalize(&env_dir).unwrap_or(env_dir);
123+
let in_project = env_dir.starts_with(&root);
124124
let shared_flat = home_dir(var).is_some_and(|h| same_path(&env_dir, &h.join(".virtualenvs")));
125125

126126
for id in project_ids(&root) {

0 commit comments

Comments
 (0)