Skip to content

Fix conda named environment creation after conda 25.11#1643

Open
jezdez wants to merge 1 commit into
microsoft:mainfrom
jezdez:fix/conda-env-prefix-discovery
Open

Fix conda named environment creation after conda 25.11#1643
jezdez wants to merge 1 commit into
microsoft:mainfrom
jezdez:fix/conda-env-prefix-discovery

Conversation

@jezdez

@jezdez jezdez commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

conda info --envs --json stopped including envs_dirs in conda 25.11. The extension persisted an empty prefix list and later searched it after conda had successfully created a named environment.

This change:

  • reads envs_dirs from full conda info --json instead of the filtered --envs response
  • treats empty cached prefix lists as stale and retries the query
  • runs named creation with --quiet --json and accepts both the current top-level prefix and legacy actions.PREFIX

References conda/conda#16430 and the named-environment failure in #1454.

@jezdez
jezdez force-pushed the fix/conda-env-prefix-discovery branch from dcedeaa to 2cf3ac7 Compare July 20, 2026 21:02
@edvilme edvilme added the bug Issue identified by VS Code Team member as probable bug label Jul 21, 2026

@edvilme edvilme 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.

LGTM :)

const state = await getWorkspacePersistentState();
const storedPrefixes = await state.get<string[]>(CONDA_PREFIXES_KEY);
if (storedPrefixes && Array.isArray(storedPrefixes)) {
if (Array.isArray(storedPrefixes) && storedPrefixes.length > 0) {

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.

Suggested change
if (Array.isArray(storedPrefixes) && storedPrefixes.length > 0) {
if (storedPrefixes?.length > 0) {

@eleanorjboyd eleanorjboyd 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.

Thanks for the contribution!

if (typeof prefix !== 'string' || prefix.trim().length === 0) {
throw new Error('conda create did not return an environment prefix');
}
return prefix;

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.

Maybe normalize the path here since the tests are failing due to casing differences with the drive

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants