Skip to content

Commit 0ae47d2

Browse files
Kartik Rajwesm
Kartik Raj
authored andcommitted
Fix support for selecting shell-like interpreter paths which may not exist on filesystem (microsoft/vscode-python#18920)
* Fix support for selecting interpreter paths which are valid when run on shells * Fix compile error
1 parent 745f491 commit 0ae47d2

File tree

1 file changed

+9
-2
lines changed
  • extensions/positron-python/src/client/pythonEnvironments/base/locators/composite

1 file changed

+9
-2
lines changed

extensions/positron-python/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '../../locator';
1919
import { PythonEnvsChangedEvent } from '../../watcher';
2020
import { resolveBasicEnv } from './resolverUtils';
21-
import { traceVerbose } from '../../../../logging';
21+
import { traceVerbose, traceWarn } from '../../../../logging';
2222
import { getEnvironmentDirFromPath, getInterpreterPathFromDir, isPythonExecutable } from '../../../common/commonUtils';
2323
import { getEmptyVersion } from '../../info/pythonVersion';
2424

@@ -167,7 +167,14 @@ function getResolvedEnv(interpreterInfo: InterpreterInformation, environment: Py
167167
async function getExecutablePathAndEnvPath(path: string) {
168168
let executablePath: string;
169169
let envPath: string;
170-
const isPathAnExecutable = await isPythonExecutable(path);
170+
const isPathAnExecutable = await isPythonExecutable(path).catch((ex) => {
171+
traceWarn('Failed to check if', path, 'is an executable', ex);
172+
// This could happen if the path doesn't exist on a file system, but
173+
// it still maybe the case that it's a valid file when run using a
174+
// shell, as shells may resolve the file extensions before running it,
175+
// so assume it to be an executable.
176+
return true;
177+
});
171178
if (isPathAnExecutable) {
172179
executablePath = path;
173180
envPath = getEnvironmentDirFromPath(executablePath);

0 commit comments

Comments
 (0)