From f68cc579abbd1e092ff2ac20f24a319e8cb9a799 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:30:55 +0000 Subject: [PATCH 1/3] Initial plan From fa47796976abcab0a593961b20b8003598357bd6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 21:39:20 +0000 Subject: [PATCH 2/3] Fix conda copy interpreter path to use actual interpreter instead of conda run command Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> --- src/features/envCommands.ts | 6 +-- .../commands/copyPathToClipboard.unit.test.ts | 54 ++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/features/envCommands.ts b/src/features/envCommands.ts index db756e84..af205613 100644 --- a/src/features/envCommands.ts +++ b/src/features/envCommands.ts @@ -30,7 +30,6 @@ import { } from '../common/pickers/managers'; import { pickProject, pickProjectMany } from '../common/pickers/projects'; import { activeTextEditor, showErrorMessage, showInformationMessage } from '../common/window.apis'; -import { quoteArgs } from './execution/execUtils'; import { runAsTask } from './execution/runAsTask'; import { runInTerminal } from './terminal/runInTerminal'; import { TerminalManager } from './terminal/terminalManager'; @@ -638,8 +637,9 @@ export async function copyPathToClipboard(item: unknown): Promise { await clipboardWriteText(projectPath); traceInfo(`Copied project path to clipboard: ${projectPath}`); } else if (item instanceof ProjectEnvironment || item instanceof PythonEnvTreeItem) { - const run = item.environment.execInfo.activatedRun ?? item.environment.execInfo.run; - const envPath = quoteArgs([run.executable, ...(run.args ?? [])]).join(' '); + // For copying interpreter path, we want the actual executable path, not the full command + const run = item.environment.execInfo.run; + const envPath = run.executable; await clipboardWriteText(envPath); traceInfo(`Copied environment path to clipboard: ${envPath}`); } else { diff --git a/src/test/features/commands/copyPathToClipboard.unit.test.ts b/src/test/features/commands/copyPathToClipboard.unit.test.ts index 2e43ce13..f0435cb5 100644 --- a/src/test/features/commands/copyPathToClipboard.unit.test.ts +++ b/src/test/features/commands/copyPathToClipboard.unit.test.ts @@ -45,7 +45,7 @@ suite('Copy Path To Clipboard', () => { await copyPathToClipboard(item); sinon.assert.calledOnce(clipboardWriteTextStub); - sinon.assert.calledWith(clipboardWriteTextStub, '/test-env/bin/test -m env'); + sinon.assert.calledWith(clipboardWriteTextStub, '/test-env/bin/test'); }); test('Copy env path to clipboard: env manager view', async () => { @@ -63,6 +63,56 @@ suite('Copy Path To Clipboard', () => { await copyPathToClipboard(item); sinon.assert.calledOnce(clipboardWriteTextStub); - sinon.assert.calledWith(clipboardWriteTextStub, '/test-env/bin/test -m env'); + sinon.assert.calledWith(clipboardWriteTextStub, '/test-env/bin/test'); + }); + + test('Copy conda env path to clipboard: should copy interpreter path not conda run command', async () => { + const item = new PythonEnvTreeItem( + { + envId: { managerId: 'conda', id: 'base' }, + name: 'base', + displayName: 'base (3.12.2)', + displayPath: '/opt/conda/envs/base', + execInfo: { + run: { executable: '/opt/conda/envs/base/bin/python' }, + activatedRun: { + executable: 'conda', + args: ['run', '--name', 'base', 'python'], + } + }, + } as PythonEnvironment, + new EnvManagerTreeItem({ name: 'conda', id: 'conda' } as InternalEnvironmentManager), + ); + + await copyPathToClipboard(item); + + sinon.assert.calledOnce(clipboardWriteTextStub); + // Should copy the actual interpreter path, not the conda run command + sinon.assert.calledWith(clipboardWriteTextStub, '/opt/conda/envs/base/bin/python'); + }); + + test('Copy conda prefix env path to clipboard: should copy interpreter path not conda run command', async () => { + const item = new PythonEnvTreeItem( + { + envId: { managerId: 'conda', id: 'myenv' }, + name: 'myenv', + displayName: 'myenv (3.11.5)', + displayPath: '/opt/conda/envs/myenv', + execInfo: { + run: { executable: '/opt/conda/envs/myenv/bin/python' }, + activatedRun: { + executable: 'conda', + args: ['run', '--prefix', '/opt/conda/envs/myenv', 'python'], + } + }, + } as PythonEnvironment, + new EnvManagerTreeItem({ name: 'conda', id: 'conda' } as InternalEnvironmentManager), + ); + + await copyPathToClipboard(item); + + sinon.assert.calledOnce(clipboardWriteTextStub); + // Should copy the actual interpreter path, not the conda run command + sinon.assert.calledWith(clipboardWriteTextStub, '/opt/conda/envs/myenv/bin/python'); }); }); From 235f6338b0bb01521f400e07868a4b07f6331e9e Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:48:52 -0700 Subject: [PATCH 3/3] formatting and remove unneeded comment --- src/features/envCommands.ts | 1 - .../commands/copyPathToClipboard.unit.test.ts | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/features/envCommands.ts b/src/features/envCommands.ts index af205613..ecdcc9bf 100644 --- a/src/features/envCommands.ts +++ b/src/features/envCommands.ts @@ -637,7 +637,6 @@ export async function copyPathToClipboard(item: unknown): Promise { await clipboardWriteText(projectPath); traceInfo(`Copied project path to clipboard: ${projectPath}`); } else if (item instanceof ProjectEnvironment || item instanceof PythonEnvTreeItem) { - // For copying interpreter path, we want the actual executable path, not the full command const run = item.environment.execInfo.run; const envPath = run.executable; await clipboardWriteText(envPath); diff --git a/src/test/features/commands/copyPathToClipboard.unit.test.ts b/src/test/features/commands/copyPathToClipboard.unit.test.ts index f0435cb5..19fac4a5 100644 --- a/src/test/features/commands/copyPathToClipboard.unit.test.ts +++ b/src/test/features/commands/copyPathToClipboard.unit.test.ts @@ -1,14 +1,14 @@ import * as sinon from 'sinon'; +import { Uri } from 'vscode'; +import { PythonEnvironment } from '../../../api'; import * as envApis from '../../../common/env.apis'; import { copyPathToClipboard } from '../../../features/envCommands'; import { - ProjectItem, + EnvManagerTreeItem, ProjectEnvironment, + ProjectItem, PythonEnvTreeItem, - EnvManagerTreeItem, } from '../../../features/views/treeViewItems'; -import { Uri } from 'vscode'; -import { PythonEnvironment } from '../../../api'; import { InternalEnvironmentManager } from '../../../internal.api'; suite('Copy Path To Clipboard', () => { @@ -73,12 +73,12 @@ suite('Copy Path To Clipboard', () => { name: 'base', displayName: 'base (3.12.2)', displayPath: '/opt/conda/envs/base', - execInfo: { + execInfo: { run: { executable: '/opt/conda/envs/base/bin/python' }, activatedRun: { executable: 'conda', args: ['run', '--name', 'base', 'python'], - } + }, }, } as PythonEnvironment, new EnvManagerTreeItem({ name: 'conda', id: 'conda' } as InternalEnvironmentManager), @@ -98,12 +98,12 @@ suite('Copy Path To Clipboard', () => { name: 'myenv', displayName: 'myenv (3.11.5)', displayPath: '/opt/conda/envs/myenv', - execInfo: { + execInfo: { run: { executable: '/opt/conda/envs/myenv/bin/python' }, activatedRun: { executable: 'conda', args: ['run', '--prefix', '/opt/conda/envs/myenv', 'python'], - } + }, }, } as PythonEnvironment, new EnvManagerTreeItem({ name: 'conda', id: 'conda' } as InternalEnvironmentManager),