Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/969.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure conda installer is not used for non-conda environments.
4 changes: 2 additions & 2 deletions src/client/common/installer/condaInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class CondaInstaller extends ModuleInstaller implements IModuleInstaller
* @returns {Promise<boolean>} Whether conda is supported as a module installer or not.
*/
public async isSupported(resource?: Uri): Promise<boolean> {
if (this.isCondaAvailable !== undefined) {
return this.isCondaAvailable!;
if (this.isCondaAvailable === false) {
return false;
}
const condaLocator = this.serviceContainer.get<ICondaService>(ICondaService);
this.isCondaAvailable = await condaLocator.isCondaAvailable();
Expand Down
16 changes: 16 additions & 0 deletions src/test/common/moduleInstaller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ suite('Module Installer', () => {
const condaInstaller = new CondaInstaller(serviceContainer.object);
await expect(condaInstaller.isSupported()).to.eventually.equal(true, 'Conda is not supported');
});
test('Ensure conda is not supported even if conda is available', async () => {
const serviceContainer = TypeMoq.Mock.ofType<IServiceContainer>();

const configService = TypeMoq.Mock.ofType<IConfigurationService>();
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(IConfigurationService))).returns(() => configService.object);
const settings = TypeMoq.Mock.ofType<IPythonSettings>();
const pythonPath = 'pythonABC';
settings.setup(s => s.pythonPath).returns(() => pythonPath);
configService.setup(c => c.getSettings(TypeMoq.It.isAny())).returns(() => settings.object);
serviceContainer.setup(c => c.get(TypeMoq.It.isValue(ICondaService))).returns(() => condaService.object);
condaService.setup(c => c.isCondaAvailable()).returns(() => Promise.resolve(true));
condaService.setup(c => c.isCondaEnvironment(TypeMoq.It.isValue(pythonPath))).returns(() => Promise.resolve(false));

const condaInstaller = new CondaInstaller(serviceContainer.object);
await expect(condaInstaller.isSupported()).to.eventually.equal(false, 'Conda should not be supported');
});

test('Validate pip install arguments', async () => {
const interpreterPath = await getCurrentPythonPath();
Expand Down