fix: read workspaceSearchPaths scoped per folder in multi-root workspaces#1448
Draft
fix: read workspaceSearchPaths scoped per folder in multi-root workspaces#1448
Conversation
…r multi-root support Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/dc6f6330-b142-4812-ad6e-de7204f2bb93 Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/dc6f6330-b142-4812-ad6e-de7204f2bb93 Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode-python-environments/sessions/dc6f6330-b142-4812-ad6e-de7204f2bb93 Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ignored workspace search paths in multi-root workspaces
fix: read workspaceSearchPaths scoped per folder in multi-root workspaces
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a multi-root workspace,
python-envs.workspaceSearchPathsset in a folder's.vscode/settings.jsonwas silently ignored.getWorkspaceSearchPaths()calledgetConfiguration('python-envs')without a scope URI, soinspect().workspaceFolderValuewas alwaysundefined— VS Code needs a folder URI to resolve per-folder settings.Changes
getWorkspaceSearchPaths(scope?: Uri)— accepts an optional folder URI and passes it togetConfiguration, allowing VS Code to return the correctworkspaceFolderValueper folder.getAllExtraSearchPaths()— replaced the single unscoped call with a per-folder loop. Each workspace folder's paths are resolved relative to that specific folder, not broadcast against all folders.folderAis not resolved againstfolderB.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh issue list --state open --limit 5 --json number,title,labels(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Problem
In a multi-root workspace,
python-envs.workspaceSearchPathsconfigured in a folder's.vscode/settings.jsonis silently ignored. This is becausegetWorkspaceSearchPaths()insrc/managers/common/nativePythonFinder.tscallsgetConfiguration('python-envs')without passing a scope URI. In VS Code's API, when no scope is provided,inspect().workspaceFolderValueisundefinedin multi-root workspaces — VS Code doesn't know which folder to inspect.Fixes #1417
Root Cause
In
src/managers/common/nativePythonFinder.ts:getWorkspaceSearchPaths()(around line 900) callsgetConfiguration('python-envs')without a scope parameter. In a multi-root workspace,inspect('workspaceSearchPaths').workspaceFolderValueis alwaysundefinedbecause VS Code needs a folder URI to know which folder's settings to return.getAllExtraSearchPaths()(around line 824) callsgetWorkspaceSearchPaths()only once (unscoped), then resolves relative paths against all workspace folders. This is incorrect for multi-root: if folderA configures./envsand folderB configures./venvs, you don't want./envsresolved against folderB.Required Fix
1.
getWorkspaceSearchPaths()— add an optionalscopeparameterChange the function signature to accept an optional
Uriscope and pass it togetConfiguration:2.
getAllExtraSearchPaths()— iterate over workspace foldersReplace the current single unscoped call with a per-folder loop. Instead of:
Do:
3. Update the existing unit tests
The existing tests in
src/test/managers/common/nativePythonFinder.getAllExtraSearchPaths.unit.test.tsmockgetConfigurationwithout a scope. The tests that exerciseworkspaceFolderValuewill need to be updated so that the mock returns the correctworkspaceFolderValuewhen called with a specific folder URI scope. Make sure all existing tests still pass, and add a new test that verifies multi-root folder-level settings are read correctly (i.e., different folders returning differentworkspaceSearchPaths).The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Tell me how to repro and debug this.
Assistant:
Let me investigate the issue and the codebase to understand how
python-envs.workspaceSearchPathsis handled and why it might be silently ignored in multi-root workspaces.Assistant: Now I have a thorough understanding of the code. Here's the root cause and how to repro/debug:
Root Cause
The bug is in
getWorkspaceSearchPaths()atnativePythonFinder.tslines 900–927. The function callsgetConfiguration('python-envs')without passing a scope (i.e., no workspace-folderUri):