Skip to content

Commit c6e011a

Browse files
author
Kartik Raj
authored
If a conda environment is not returned via the conda env list command, resolve it as unknown (#18856)
* If a conda environment is not returned via the conda env list command, resolve it as unknown * News entry * Fix unit tests
1 parent 905394d commit c6e011a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

news/2 Fixes/18530.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If a conda environment is not returned via the `conda env list` command, consider it as unknown env type.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ async function resolveCondaEnv(env: BasicEnvInfo, useCache?: boolean): Promise<P
173173
} info' command`,
174174
);
175175
// Environment could still be valid, resolve as a simple env.
176+
env.kind = PythonEnvKind.Unknown;
176177
return resolveSimpleEnv(env);
177178
}
178179

src/test/pythonEnvironments/base/locators/composite/resolverUtils.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ suite('Resolver Utils', () => {
280280
);
281281
});
282282

283-
test('resolveEnv: If no conda binary found, resolve as a simple environment', async () => {
283+
test('resolveEnv: If no conda binary found, resolve as an unknown environment', async () => {
284284
sinon.stub(platformApis, 'getOSType').callsFake(() => platformApis.OSType.Windows);
285285
sinon.stub(externalDependencies, 'shellExecute').callsFake(async (command: string) => {
286286
throw new Error(`${command} is missing or is not executable`);
@@ -293,7 +293,7 @@ suite('Resolver Utils', () => {
293293
actual,
294294
createSimpleEnvInfo(
295295
path.join(TEST_LAYOUT_ROOT, 'conda1', 'python.exe'),
296-
PythonEnvKind.Conda,
296+
PythonEnvKind.Unknown,
297297
undefined,
298298
'conda1',
299299
path.join(TEST_LAYOUT_ROOT, 'conda1'),
@@ -616,8 +616,8 @@ suite('Resolver Utils', () => {
616616
});
617617
const expected = buildEnvInfo({
618618
location: path.join(regTestRoot, 'conda3'),
619-
// Environment should already be marked as Conda. No need to update it to Global.
620-
kind: PythonEnvKind.Conda,
619+
// Environment is not marked as Conda, update it to Global.
620+
kind: PythonEnvKind.OtherGlobal,
621621
executable: interpreterPath,
622622
// Registry does not provide the minor version, so keep version provided by Conda resolver instead.
623623
version: parseVersion('3.8.5'),

0 commit comments

Comments
 (0)