diff --git a/apps/desktop/electron/source-backend.test.ts b/apps/desktop/electron/source-backend.test.ts index 5809c7039f..5c2fb0fad1 100644 --- a/apps/desktop/electron/source-backend.test.ts +++ b/apps/desktop/electron/source-backend.test.ts @@ -183,8 +183,9 @@ test.skipIf(process.platform === 'win32')( assert.ok(source) assert.equal(source.command, fixture.python) assert.match( + // The real spawn runs in the user's workspace, never the checkout. execFileSync(source.command, source.args, { - cwd: source.root, + cwd: temp, env: { ...env, ...source.env }, encoding: 'utf8', timeout: 15_000 @@ -224,7 +225,7 @@ test('Windows console selection uses only the selected interpreter directory', ( fs.writeFileSync(consolePython, '') const backend: SourceBackend | null = createSourcePythonBackend(root, selected, ['serve'], { isWindows: true }) assert.equal(backend?.command, consolePython) - assert.equal(backend?.env.PYTHONPATH, '') + assert.equal(backend?.env.PYTHONPATH, root) assert.equal(backend?.env.PYTHONHOME, '') assert.equal(createSourcePythonBackend(root, selected, [], { isWindows: false })?.command, selected) assert.equal(createSourcePythonBackend(root, null, []), null) diff --git a/apps/desktop/electron/source-backend.ts b/apps/desktop/electron/source-backend.ts index 40bf2c1991..954fec0ad7 100644 --- a/apps/desktop/electron/source-backend.ts +++ b/apps/desktop/electron/source-backend.ts @@ -96,7 +96,10 @@ export function createSourcePythonBackend( label: `Hermes source at ${root}`, command, args: ['-m', 'hermes_cli.main', ...args], - env: buildDesktopBackendEnv({ currentEnv: options.env ?? process.env }), + // The backend runs in the user's workspace cwd, and the selected + // interpreter need not have this checkout installed: name it explicitly. + // (The scrubbed inherited value could point at another checkout.) + env: { ...buildDesktopBackendEnv({ currentEnv: options.env ?? process.env }), PYTHONPATH: root }, root, bootstrap: false, shell: false,