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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant