fix: prepend PowerShell call operator when activating environments#197
Merged
Merged
Conversation
PowerShell parses a leading quoted string as an expression, so when the Hatch executable path contains a space (e.g. under "C:\Program Files"), the host-quoted activation command failed with a ParserError and the environment was not activated. Add a pwsh-specific shellActivation entry that prefixes the call operator `&`, matching how the built-in venv/poetry managers handle PowerShell. cmd/bash/zsh/fish keep using the shared entry, where `&` is neither needed nor valid. Fixes pypa#196
Member
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #196.
Problem
Activating a Hatch environment in a PowerShell terminal fails with a
ParserErrorwhen the Hatch executable path contains a space (e.g. the standalone installer'sC:\Program Files\Hatch\hatch.EXE). The host quotes the executable, and PowerShell parses a leading quoted string as an expression rather than a command to run:Invoking a quoted executable in PowerShell requires the call operator
&. Thems-python.vscode-python-envshost adds it automatically on its run path (runInTerminal.ts) but not on the activation path (getShellCommandAsString), so the manager has to supply it for PowerShell — which the built-in venv/poetry managers do, but this manager did not.Fix
Add a
pwsh-specificshellActivationentry that prefixes the call operator, matching the built-in managers ({ executable: '&', args: [...] }). A lone&is left unquoted by the host's quoting, producing:'pwsh'covers both Windows PowerShell 5.x and PowerShell 7; cmd/bash/zsh/fish keep using the shared'unknown'entry, where&is neither needed nor valid. The--envflag and its value are now passed as separate args so only the value is quoted when needed.Testing
Verified manually on Windows with PowerShell — activation now works.
tsc --noEmitandbiome checkpass.