Skip to content

Commit e527bf3

Browse files
author
Kartik Raj
committed
Do not assume envPath is provided
1 parent 33abf8e commit e527bf3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/client/pythonEnvironments/base/locators/composite/resolverUtils.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,35 +158,34 @@ async function resolveSimpleEnv(env: BasicEnvInfo): Promise<PythonEnvInfo> {
158158
async function resolveCondaEnv(env: BasicEnvInfo): Promise<PythonEnvInfo> {
159159
const { executablePath } = env;
160160
const conda = await Conda.getConda();
161-
if (conda === undefined || !env.envPath) {
162-
const errorMsg =
163-
conda === undefined
164-
? `${executablePath} identified as Conda environment even though Conda is not found`
165-
: `Conda environment ${executablePath} does not have envPath`;
166-
traceError(errorMsg);
161+
if (conda === undefined) {
162+
traceWarn(`${executablePath} identified as Conda environment even though Conda is not found`);
167163
// Environment could still be valid, resolve as a simple env.
168164
env.kind = PythonEnvKind.Unknown;
169165
const envInfo = await resolveSimpleEnv(env);
170166
envInfo.type = PythonEnvType.Conda;
167+
// Assume it's a prefixed env by default because prefixed CLIs work even for named environments.
168+
envInfo.name = '';
171169
return envInfo;
172170
}
173171

172+
const envPath = env.envPath ?? getEnvironmentDirFromPath(env.executablePath);
174173
let executable: string;
175174
if (env.executablePath.length > 0) {
176175
executable = env.executablePath;
177176
} else {
178-
executable = await conda.getInterpreterPathForEnvironment({ prefix: env.envPath });
177+
executable = await conda.getInterpreterPathForEnvironment({ prefix: envPath });
179178
}
180179
const info = buildEnvInfo({
181180
executable,
182181
kind: PythonEnvKind.Conda,
183182
org: AnacondaCompanyName,
184-
location: env.envPath,
183+
location: envPath,
185184
source: [],
186185
version: executable ? await getPythonVersionFromPath(executable) : undefined,
187186
type: PythonEnvType.Conda,
188187
});
189-
const name = await conda?.getName(env.envPath);
188+
const name = await conda?.getName(envPath);
190189
if (name) {
191190
info.name = name;
192191
}

0 commit comments

Comments
 (0)