@@ -9,7 +9,7 @@ import { Uri, Disposable, Extension, extensions } from 'vscode';
99import * as path from 'path' ;
1010import * as pythonApi from '../../../extension/common/python' ;
1111import * as utilities from '../../../extension/common/utilities' ;
12- import { buildPythonEnvironment } from './helpers' ;
12+ import { buildPythonEnvironment , buildPythonEnvironmentWithActivatedRun } from './helpers' ;
1313
1414// Platform-specific path constants using path.join so tests assert using native separators.
1515// Leading root '/' preserved; on Windows this yields a leading backslash (e.g. '\\usr\\bin').
@@ -166,6 +166,24 @@ suite('Python API Tests- useEnvironmentsExtension:true', () => {
166166
167167 expect ( result ) . to . be . undefined ;
168168 } ) ;
169+
170+ test ( 'Should use run.executable instead of activatedRun.executable when they differ' , async ( ) => {
171+ // Simulates environment managers like pixi/conda that set activatedRun to a wrapper command
172+ const actualPythonPath = PYTHON_PATH ;
173+ const wrapperCommand = path . join ( '/' , 'usr' , 'local' , 'bin' , 'pixi' ) ;
174+ const mockPythonEnv = buildPythonEnvironmentWithActivatedRun ( actualPythonPath , wrapperCommand , '3.9.0' , [
175+ 'run' ,
176+ 'python' ,
177+ ] ) ;
178+ ( mockEnvsExtension as any ) . exports = mockPythonEnvApi ;
179+ mockPythonEnvApi . getEnvironment . resolves ( mockPythonEnv ) ;
180+ mockPythonEnvApi . resolveEnvironment . resolves ( mockPythonEnv ) ;
181+
182+ const result = await pythonApi . getSettingsPythonPath ( ) ;
183+
184+ // Should return the actual Python binary path, not the wrapper command
185+ expect ( result ) . to . deep . equal ( [ actualPythonPath ] ) ;
186+ } ) ;
169187 } ) ;
170188
171189 suite ( 'getEnvironmentVariables' , ( ) => {
@@ -374,6 +392,26 @@ suite('Python API Tests- useEnvironmentsExtension:true', () => {
374392
375393 expect ( result . path ) . to . be . undefined ;
376394 } ) ;
395+
396+ test ( 'Should use run.executable instead of activatedRun.executable when they differ' , async ( ) => {
397+ // Simulates environment managers like pixi/conda that set activatedRun to a wrapper command
398+ const actualPythonPath = PYTHON_PATH ;
399+ const wrapperCommand = path . join ( '/' , 'usr' , 'local' , 'bin' , 'pixi' ) ;
400+ const mockEnv = buildPythonEnvironmentWithActivatedRun ( actualPythonPath , wrapperCommand , '3.9.0' , [
401+ 'run' ,
402+ 'python' ,
403+ ] ) ;
404+
405+ ( mockEnvsExtension as any ) . exports = mockPythonEnvApi ;
406+ mockPythonEnvApi . getEnvironment . returns ( { environmentPath : Uri . file ( actualPythonPath ) } ) ;
407+ mockPythonEnvApi . resolveEnvironment . resolves ( mockEnv ) ;
408+
409+ const result = await pythonApi . getInterpreterDetails ( ) ;
410+
411+ // Should return the actual Python binary path, not the wrapper command
412+ expect ( result . path ) . to . deep . equal ( [ actualPythonPath ] ) ;
413+ expect ( result . resource ) . to . be . undefined ;
414+ } ) ;
377415 } ) ;
378416
379417 suite ( 'onDidChangePythonInterpreter event' , ( ) => {
0 commit comments