Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/client/pythonEnvironments/base/info/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,20 @@ export function areSameEnv(
if (leftInfo === undefined || rightInfo === undefined) {
return undefined;
}
const leftFilename = leftInfo.executable!.filename;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of the bang ! here is wrong, compiler says it can be undefined, but we're ignoring that.
And we run into issues as a result.

const rightFilename = rightInfo.executable!.filename;

if (
(leftInfo.executable?.filename && !rightInfo.executable?.filename) ||
(!leftInfo.executable?.filename && rightInfo.executable?.filename)
) {
return false;
}
if (leftInfo.id && leftInfo.id === rightInfo.id) {
// In case IDs are available, use it.
return true;
}

const leftFilename = leftInfo.executable!.filename;
const rightFilename = rightInfo.executable!.filename;

if (getEnvID(leftFilename, leftInfo.location) === getEnvID(rightFilename, rightInfo.location)) {
// Otherwise use ID function to get the ID. Note ID returned by function may itself change if executable of
// an environment changes, for eg. when conda installs python into the env. So only use it as a fallback if
Expand Down