-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PR
Description
Problem
Per project learnings documented in .github/instructions/generic.instructions.md:
path.normalize() vs path.resolve(): On Windows,
path.normalize('\test')keeps it as\test, butpath.resolve('\test')adds the current drive →C:\test. When comparing paths, usepath.resolve()on BOTH sides or they won't match.
Multiple manager implementations use path.normalize() for path comparisons, which can cause matching failures on Windows.
Affected Code
pyenvManager.ts L259:
private findEnvironmentByPath(fsPath: string): PythonEnvironment | undefined {
const normalized = path.normalize(fsPath);
return this.collection.find((e) => {
const n = path.normalize(e.environmentPath.fsPath);
return n === normalized || path.dirname(n) === normalized || path.dirname(path.dirname(n)) === normalized;
});
}poetryManager.ts L244:
private findEnvironmentByPath(fsPath: string): PythonEnvironment | undefined {
const normalized = path.normalize(fsPath);
return this.collection.find((e) => {
const n = path.normalize(e.environmentPath.fsPath);
return n === normalized || path.dirname(n) === normalized || path.dirname(path.dirname(n)) === normalized;
});
}Expected Behavior
Path comparisons should use path.resolve() on both sides to ensure drive letters are properly added on Windows.
Suggested Fix
private findEnvironmentByPath(fsPath: string): PythonEnvironment | undefined {
const normalized = path.resolve(fsPath);
return this.collection.find((e) => {
const n = path.resolve(e.environmentPath.fsPath);
return n === normalized || path.dirname(n) === normalized || path.dirname(path.dirname(n)) === normalized;
});
}Affected Files
src/managers/pyenv/pyenvManager.tssrc/managers/poetry/poetryManager.ts- Potentially other files using
path.normalize()for path equality checks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PR