Skip to content

Commit 55410f6

Browse files
authored
Fix installation of codna packages when conda environment has spaces (#2782)
For #2015
1 parent 3077ac0 commit 55410f6

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

news/2 Fixes/2015.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix installation of codna packages when conda environment contains spaces.

src/client/common/installer/condaInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export class CondaInstaller extends ModuleInstaller implements IModuleInstaller
6565
if (info && info.name) {
6666
// If we have the name of the conda environment, then use that.
6767
args.push('--name');
68-
args.push(info.name!);
68+
args.push(info.name!.toCommandArgument());
6969
} else if (info && info.path) {
7070
// Else provide the full path to the environment path.
7171
args.push('--prefix');
72-
args.push(info.path);
72+
args.push(info.path.fileToCommandArgument());
7373
}
7474
args.push(moduleName);
7575
return {

src/test/common/installer/moduleInstaller.unit.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ suite('Module Installer', () => {
4343
proxyServers.forEach(proxyServer => {
4444
[undefined, Uri.file('/users/dev/xyz')].forEach(resource => {
4545
// Conda info is relevant only for CondaInstaller.
46-
const condaEnvs = installerClass === CondaInstaller ? [{ name: 'My-Env01', path: '' }, { name: '', path: '/conda/path' }] : [];
46+
const condaEnvs = installerClass === CondaInstaller ? [
47+
{ name: 'My-Env01', path: '' }, { name: '', path: path.join('conda', 'path') },
48+
{ name: 'My-Env01 With Spaces', path: '' }, { name: '', path: path.join('conda with spaces', 'path') }
49+
] : [];
4750
[undefined, ...condaEnvs].forEach(condaEnvInfo => {
4851
const testProxySuffix = proxyServer.length === 0 ? 'without proxy info' : 'with proxy info';
4952
const testCondaEnv = condaEnvInfo ? (condaEnvInfo.name ? 'without conda name' : 'with conda path') : 'without conda';
@@ -144,10 +147,10 @@ suite('Module Installer', () => {
144147
const expectedArgs = ['install'];
145148
if (condaEnvInfo && condaEnvInfo.name) {
146149
expectedArgs.push('--name');
147-
expectedArgs.push(condaEnvInfo.name);
150+
expectedArgs.push(condaEnvInfo.name.toCommandArgument());
148151
} else if (condaEnvInfo && condaEnvInfo.path) {
149152
expectedArgs.push('--prefix');
150-
expectedArgs.push(condaEnvInfo.path);
153+
expectedArgs.push(condaEnvInfo.path.fileToCommandArgument());
151154
}
152155
expectedArgs.push('"pylint<2.0.0"');
153156
await installModuleAndVerifyCommand(condaExecutable, expectedArgs);
@@ -176,10 +179,10 @@ suite('Module Installer', () => {
176179
const expectedArgs = ['install'];
177180
if (condaEnvInfo && condaEnvInfo.name) {
178181
expectedArgs.push('--name');
179-
expectedArgs.push(condaEnvInfo.name);
182+
expectedArgs.push(condaEnvInfo.name.toCommandArgument());
180183
} else if (condaEnvInfo && condaEnvInfo.path) {
181184
expectedArgs.push('--prefix');
182-
expectedArgs.push(condaEnvInfo.path);
185+
expectedArgs.push(condaEnvInfo.path.fileToCommandArgument());
183186
}
184187
expectedArgs.push('pylint');
185188
await installModuleAndVerifyCommand(condaExecutable, expectedArgs);
@@ -223,10 +226,10 @@ suite('Module Installer', () => {
223226
const expectedArgs = ['install'];
224227
if (condaEnvInfo && condaEnvInfo.name) {
225228
expectedArgs.push('--name');
226-
expectedArgs.push(condaEnvInfo.name);
229+
expectedArgs.push(condaEnvInfo.name.toCommandArgument());
227230
} else if (condaEnvInfo && condaEnvInfo.path) {
228231
expectedArgs.push('--prefix');
229-
expectedArgs.push(condaEnvInfo.path);
232+
expectedArgs.push(condaEnvInfo.path.fileToCommandArgument());
230233
}
231234
expectedArgs.push(moduleName);
232235
await installModuleAndVerifyCommand(condaExecutable, expectedArgs);

0 commit comments

Comments
 (0)