Commit 69be6a4
authored
Fix wrong Python executable path on Linux/macOS after creating conda environments (#1459)
Part of
#1454
## Bug
In `createNamedCondaEnvironment` and `createPrefixCondaEnvironment`, the
Python executable path is computed as:
```ts
const bin = os.platform() === 'win32' ? 'python.exe' : 'python';
// Then: path.join(envPath, bin)
```
On Linux/macOS, this produces `/path/to/env/python`, but conda installs
the Python executable at `/path/to/env/bin/python`.
## Why it's a bug
The environment appears in the VS Code picker and can be selected.
However, the internal `execInfo.run.executable` points to a non-existent
path. Any operation that invokes Python — running scripts, linting,
getting version info — fails silently. Users see a valid-looking conda
environment that they can select, but nothing works after selecting it.
The `quickCreateConda` function (line 1225) already had the correct
path:
```ts
os.platform() === 'win32' ? path.join(prefix, 'python.exe') : path.join(prefix, 'bin', 'python')
```
## Repro steps
1. On Linux or macOS, create a conda environment through the VS Code UI
(either named or prefix type).
2. The environment appears in the picker — select it.
3. Try running a Python script or checking the Python version.
4. Operations fail because the executable path `/path/to/env/python`
does not exist.
## Fix
Changed both `createNamedCondaEnvironment` (line 1085) and
`createPrefixCondaEnvironment` (line 1169) to use:
```ts
const bin = os.platform() === 'win32' ? 'python.exe' : path.join('bin', 'python');
```
This matches the correct pattern already used in `quickCreateConda`.
## Tests added
- `condaUtils.pythonExePath.unit.test.ts`: 3 test cases verifying
correct executable paths for both platform types and both environment
types.1 parent ee40206 commit 69be6a4
2 files changed
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | | - | |
| 1085 | + | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
| |||
1166 | 1166 | | |
1167 | 1167 | | |
1168 | 1168 | | |
1169 | | - | |
| 1169 | + | |
1170 | 1170 | | |
1171 | 1171 | | |
1172 | 1172 | | |
| |||
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments