Skip to content

Use the call operator for PowerShell terminal activation - #58

Open
SIDLAD wants to merge 1 commit into
prefix-dev:mainfrom
SIDLAD:fix/pwsh-activation-call-operator
Open

SIDLAD wants to merge 1 commit into
prefix-dev:mainfrom
SIDLAD:fix/pwsh-activation-call-operator

Conversation

@SIDLAD

@SIDLAD SIDLAD commented Nov 8, 2026

Copy link
Copy Markdown

This fixes it by putting PowerShell's call operator & in front of the command, so the quoted path runs as a command. I tested the fix by running the extension from source (F5 / Extension Development Host): PowerShell and cmd both activate the environment.


AI-assisted details (written with Claude Code)

Fixes #56.

Change (src/pixi/utils.ts)

  • Adds execInfo.shellActivation with a single pwsh entry: { executable: '&', args: [pixi, 'shell', '--manifest-path', <manifest>, '-e', <env>] }.
    • The pwsh key covers both Windows PowerShell 5.1 and PowerShell 7.
    • quoteArgs leaves a lone & unquoted, so the result is & "C:\...\pixi.exe" shell ....
  • Other shells aren't in the map, so they fall back to the existing activation unchanged (per getShellActivationCommand).
  • Pulls the shared shell args into a shellArgs const to avoid duplication.

Checks

  • npm run lint, npm run format:check and npm run compile all pass.

Testing

  • Same machine and setup as the PR for Fails on Windows, when there is a space in the home directory path #8, run via F5 with both fixes applied:
    • PowerShell: & "C:\Users\First Last\.pixi\bin\pixi.EXE" shell --manifest-path D:\Projects\LearningMLDL\pixi.toml -e default → prompt becomes (LearningMLDL) PS …. Before this change, the same terminal failed with Unexpected token 'shell'.
    • Command Prompt: unchanged, "C:\…\pixi.EXE" shell … → (LearningMLDL) ….

Side note for anyone testing via F5: when the extension runs from a folder whose path doesn't contain renan-r-santos.pixi-code (e.g. a plain pixi-code clone), Python Environments' caller detection files the manager as ms-python.python:pixi. Selecting a Pixi env then fails with No environment manager found for [renan-r-santos.pixi-code:pixi]. For local testing only, I passed { extensionId: 'renan-r-santos.pixi-code' } to registerEnvironmentManager/registerPackageManager. That isn't part of this PR, but it could be worth doing for robustness.

Notes

🤖 Generated with Claude Code

The Python Environments extension quotes the activation executable and
runs it with Invoke-Expression. PowerShell parses a leading quoted path
as a string expression, so activation failed with "Unexpected token
'shell'" whenever the pixi path contained a space. Provide a pwsh-specific
shellActivation that prefixes the call operator '&', the same approach the
built-in venv and conda managers use. Other shells keep using activation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerShell terminal activation fails when the pixi path contains a space

1 participant