Commit 7551eb5
authored
fix: streamline environment retrieval in venvManager and pyenvManager (microsoft#1157)
Fixes microsoft#610
## Summary
This PR enables pyenv-installed Python versions to appear as available
base interpreters when creating new venv environments.
## Changes
### 1. Fixed bug in `PyEnvManager.getEnvironments()`
The filter callback for the `'global'` scope was missing a return
statement - it used braces without returning a value, causing it to
always return an empty array:
```typescript
// Before (buggy):
return this.collection.filter((env) => {
env.group === PYENV_VERSIONS; // Statement - doesn't return anything
});
// After (fixed):
return this.collection.filter((env) => env.group === PYENV_VERSIONS);
```
### 2. Updated `VenvManager` to use API for aggregating global
environments
Changed from using only `baseManager.getEnvironments('global')` (which
only returns system Python) to `api.getEnvironments('global')` which
aggregates environments from ALL registered managers including pyenv,
conda, etc.
This change was applied to three locations in `venvManager.ts`:
- `create()` method - when showing available base interpreters for venv
creation
- `resetGlobalEnv()` method - when resetting the global environment
reference
- `loadEnvMap()` method - when loading environment mappings
## Result
When users create a new venv environment, pyenv-installed Python
versions (those in the `PYENV_VERSIONS` group) will now appear alongside
system Python installations as available base interpreters.1 parent 5e4a386 commit 7551eb5
2 files changed
+2
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
| |||
0 commit comments