Skip to content

Commit a385096

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,35 +158,32 @@ 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;
171167
return envInfo;
172168
}
173169

170+
const envPath = env.envPath ?? getEnvironmentDirFromPath(env.executablePath);
174171
let executable: string;
175172
if (env.executablePath.length > 0) {
176173
executable = env.executablePath;
177174
} else {
178-
executable = await conda.getInterpreterPathForEnvironment({ prefix: env.envPath });
175+
executable = await conda.getInterpreterPathForEnvironment({ prefix: envPath });
179176
}
180177
const info = buildEnvInfo({
181178
executable,
182179
kind: PythonEnvKind.Conda,
183180
org: AnacondaCompanyName,
184-
location: env.envPath,
181+
location: envPath,
185182
source: [],
186183
version: executable ? await getPythonVersionFromPath(executable) : undefined,
187184
type: PythonEnvType.Conda,
188185
});
189-
const name = await conda?.getName(env.envPath);
186+
const name = await conda?.getName(envPath);
190187
if (name) {
191188
info.name = name;
192189
}

0 commit comments

Comments
 (0)