Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79e8a13

Browse files
authored
Always use environment path when running conda environment commands (#24807)
Attempt at fixing#24585There are many edge scenarious where refering to the name of theenvironment rather than the path can cause breaks in the extension. Someexamples1 -**If we have two anonymous environments with the same name indifferent folders**/path1/my-env/path2/my-env (where my active vscode python interpreter is)by using conda -n my-env it'll always use the first env.2 - **Some times people avoid actually activating their conda envs whenusing conda-pack**https://github.com/conda/conda-packThis is because the activation scripts are known to be flaky and notvery reliable3 - **The environment may have been created by a conda-compliantreplacement**Therefore conda itself is not aware of it by name but can work with itproperly using the path. This is the case of[hawk](https://community.palantir.com/t/introducing-hawk-for-python-package-management-in-code-repositories/500)or frankly anyone building their own conda package manager on top of[rattler](https://github.com/conda/rattler).Some of these points are also hinted at#24627 (comment), and supported by a conda maintainer in#24585 (comment)This PR has a minimal attempt at changing that by always forcing -pusage
1 parentb4aa112 commit79e8a13

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

‎src/client/pythonEnvironments/common/environmentManagers/conda.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,8 @@ export class Conda {
564564
returnundefined;
565565
}
566566
constargs=[];
567-
if(env.name){
568-
args.push('-n',env.name);
569-
}else{
570-
args.push('-p',env.prefix);
571-
}
567+
args.push('-p',env.prefix);
568+
572569
constpython=[
573570
forShellExecution ?this.shellCommand :this.command,
574571
'run',

‎src/test/common/process/pythonEnvironment.unit.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,16 @@ suite('CondaEnvironment', () => {
284284

285285
teardown(()=>sinon.restore());
286286

287-
test('getExecutionInfo with a named environment should return execution info using the environmentname',async()=>{
287+
test('getExecutionInfo with a named environment should return execution info using the environmentpath',async()=>{
288288
constcondaInfo={name:'foo',path:'bar'};
289289
constenv=awaitcreateCondaEnv(condaInfo,processService.object,fileSystem.object);
290290

291291
constresult=env?.getExecutionInfo(args,pythonPath);
292292

293293
expect(result).to.deep.equal({
294294
command:condaFile,
295-
args:['run','-n',condaInfo.name,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT, ...args],
296-
python:[condaFile,'run','-n',condaInfo.name,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
295+
args:['run','-p',condaInfo.path,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT, ...args],
296+
python:[condaFile,'run','-p',condaInfo.path,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
297297
pythonExecutable:pythonPath,
298298
});
299299
});
@@ -312,12 +312,12 @@ suite('CondaEnvironment', () => {
312312
});
313313
});
314314

315-
test('getExecutionObservableInfo with a named environment should return execution info using conda full path with thename',async()=>{
315+
test('getExecutionObservableInfo with a named environment should return execution info using conda full path with thepath',async()=>{
316316
constcondaInfo={name:'foo',path:'bar'};
317317
constexpected={
318318
command:condaFile,
319-
args:['run','-n',condaInfo.name,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT, ...args],
320-
python:[condaFile,'run','-n',condaInfo.name,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
319+
args:['run','-p',condaInfo.path,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT, ...args],
320+
python:[condaFile,'run','-p',condaInfo.path,'--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
321321
pythonExecutable:pythonPath,
322322
};
323323
constenv=awaitcreateCondaEnv(condaInfo,processService.object,fileSystem.object);

‎src/test/pythonEnvironments/common/environmentManagers/conda.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ suite('Conda and its environments are located correctly', () => {
536536
expect(args).to.not.equal(undefined);
537537
assert.deepStrictEqual(
538538
args,
539-
['conda','run','-n','envName','--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
539+
['conda','run','-p','envPrefix','--no-capture-output','python',OUTPUT_MARKER_SCRIPT],
540540
'Incorrect args for case 1',
541541
);
542542

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp