Skip to content

Fix duplicate Conda environments after restart - #1939

Merged
Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:stellahuang-microsoft-ideal-goggles
Oct 20, 2026
Merged

Stella Huang (StellaHuang95) merged 1 commit into
microsoft:mainfrom
StellaHuang95:stellahuang-microsoft-ideal-goggles

Conversation

@StellaHuang95

@StellaHuang95 Stella Huang (StellaHuang95) commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • serialize Conda startup and explicit inventory rebuilds so persisted-selection restoration cannot append the same external prefix twice
  • canonicalize resolved global and project selections by normalized environment path while preserving fast-path startup and selection identity
  • add deterministic regression coverage for both persistence scopes, refresh events, no-Python updates, and cross-platform path spellings

Validation

  • npm run lint
  • npm run compile-tests
  • npm run unittest (3,300 passing, 9 pending)
  • npm run compile
  • smoke tests (30 passing, 1 pending)
  • baseline VS Code E2E tests (4 passing)
  • manual two-process restart in ordinary VS Code 1.142.0 using Conda 26.9.3 and an isolated, unregistered external Python 3.11.17 prefix:
    • target absent from initial discovery, then selected and persisted as one underlying object
    • same profile/workspace reopened with startup getEnvironment() and explicit refresh triggered concurrently; one underlying object remained and selection was restored
    • real environment picker rendered and was cancelled without changing selection
    • subsequent explicit refresh retained one object and the same selected prefix
    • selected interpreter executed a probe successfully with the expected sys.prefix and executable

Fixes #1870

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 965f9204-0368-49bf-a79d-6243a3e10ed6
@StellaHuang95 Stella Huang (StellaHuang95) added the bug Issue identified by VS Code Team member as probable bug label Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes address the reported race with deterministic regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes duplicate Conda environments after restart by coordinating inventory rebuilds and reusing canonical environment objects for persisted selections.

Changes:

  • Serializes startup discovery and explicit refreshes.
  • Deduplicates resolved selections by normalized environment path.
  • Adds deterministic regression tests for both persistence scopes, refresh events, and path variants.
File Description
src/​test/​managers/​conda/​condaEnvManager.refreshRace.unit.test.ts Tests concurrent restoration, refresh ordering, and selection identity.
src/​managers/​conda/​condaEnvManager.ts Queues inventory rebuilds and canonicalizes resolved environments.

Review effort: Balanced

@rchiodo

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved via Review Center.

@rchiodo Rich Chiodo (rchiodo) added the review-auto:approved Automated review: no blocking findings (approval posted). label Oct 20, 2026

@bschnurr Bill Schnurr (bschnurr) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved via Review Center.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved via Review Center.

@StellaHuang95
Stella Huang (StellaHuang95) merged commit 4f44915 into microsoft:main Oct 20, 2026
59 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External Conda environment appears twice after restart

5 participants