Skip to content

fix: expand ~ in python.venvFolders entries - #1828

Open
Alexandre Kohler (kwy404) wants to merge 1 commit into
microsoft:mainfrom
kwy404:fix/untildify-venv-folders
Open

Alexandre Kohler (kwy404) wants to merge 1 commit into
microsoft:mainfrom
kwy404:fix/untildify-venv-folders

Conversation

@kwy404

Copy link
Copy Markdown

Problem

python.venvFolders entries that start with ~ are never searched. The settings reference lists ~/.virtualenvs as an example value for this setting and says it is merged with python-envs.globalSearchPaths.

getPythonSettingAndUntildify only expands ~ when the setting value is a string. For arrays it returns the value unchanged, so an entry like ~/envs reaches PET as the literal path ~/envs. PET does not expand ~ there, so the folder is skipped. The same ~/envs works in python-envs.globalSearchPaths, because those entries go through untildifyArray.

The existing unit test noted this ("only untildifies strings, not array items") and passed a pre-expanded path to work around it.

Fix

Expand each entry when the setting value is an array. This covers the three places in nativePythonFinder.ts that read venvFolders: the configure request (getAllExtraSearchPaths), targeted refreshes (getRefreshOptions) and the JSON CLI fallback.

Tests

  • Updated Legacy paths with untildify support in nativePythonFinder.getAllExtraSearchPaths.unit.test.ts to pass ~/conda/envs in venvFolders instead of a pre-expanded path, and removed the note. It fails without the fix (~/conda/envs is returned as is) and passes with it.
  • npm run unittest (Windows, Node 24): 2429 passing, 4 pending.
  • npm run lint, npm run compile-tests and npm run compile pass.

getPythonSettingAndUntildify only expanded string settings, so
python.venvFolders entries such as ~/envs were sent to PET unchanged
and those folders were never searched. Expand each array entry the
same way python-envs.globalSearchPaths entries are expanded.
@edvilme Eduardo Villalpando Mello (edvilme) added the bug Issue identified by VS Code Team member as probable bug label Sep 28, 2026

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.

Thanks for taking the time to fix this, will let the tests run and let you know if anything comes up! :)

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

4 participants