Fix wrong Python executable path on Linux/macOS after creating conda environments#1459
Merged
eleanorjboyd merged 1 commit intomicrosoft:mainfrom Apr 22, 2026
Conversation
Member
|
@karthiknadig could you give this a quick once-over since it is windows related |
eleanorjboyd
approved these changes
Apr 22, 2026
StellaHuang95
added a commit
to StellaHuang95/vscode-python-environments
that referenced
this pull request
Apr 30, 2026
…environments (microsoft#1459) Part of microsoft#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.
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.
Part of #1454
Bug
In
createNamedCondaEnvironmentandcreatePrefixCondaEnvironment, the Python executable path is computed as: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.executablepoints 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
quickCreateCondafunction (line 1225) already had the correct path:Repro steps
/path/to/env/pythondoes not exist.Fix
Changed both
createNamedCondaEnvironment(line 1085) andcreatePrefixCondaEnvironment(line 1169) to use: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.