fix(powershell): source shellenv via Out-String so the profile line loads - #135
Merged
Conversation
timvw
enabled auto-merge (squash)
August 19, 2026 16:39
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
==========================================
+ Coverage 37.76% 37.82% +0.06%
==========================================
Files 33 33
Lines 3509 3506 -3
==========================================
+ Hits 1325 1326 +1
+ Misses 2090 2085 -5
- Partials 94 95 +1
🚀 New features to boost your workflow:
|
…oads The documented $PROFILE line, Invoke-Expression (& wt shellenv powershell), fails on Windows PowerShell 5.1. shellenv emits many lines, so the subexpression evaluates to an Object[] and Invoke-Expression's -Command parameter ([string]) rejects it. The wt function is never defined, so auto-cd, completion and the interactive menus are silently absent while wt.exe on PATH keeps plain commands working. Pipe through Out-String instead, and hoist the line into a shared powershellSetupLine constant used by wt init and the shellenv help. CI missed this because the E2E harness sourced shellenv via its own pre-joined variant rather than the documented form; it now uses the documented pipeline, and a test pins docs/installation.md and e2e/run.go to it. Fixes #130
… e2e The bash leg already names its shell; the PowerShell legs relied on auto-detection, so a stray MSYSTEM/SHELL in the runner environment could have fed the bash integration into Invoke-Expression. Naming powershell also makes the harness match the documented $PROFILE line exactly.
timvw
force-pushed
the
fix/130-powershell-shellenv
branch
from
August 19, 2026 16:56
9bfe965 to
d139e17
Compare
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 #130.
The bug
The
$PROFILElinewt init powershellwrites (and the docs tell users to addby hand) does not work:
shellenvemits many lines, so the subexpression evaluates toObject[], andInvoke-Expression's-Commandparameter is[string]. The call is rejected,the
wtfunction is never defined, and auto-cd, tab completion and theinteractive menus are all silently absent —
wtkeeps working becausewt.exeis on
PATH, so the failure is easy to miss once the error scrolls away.I reproduced the exact error on PowerShell 7 as well, so this is not limited to
Windows PowerShell 5.1.
The fix
Hoisted into a single
powershellSetupLineconstant sowt init, theshellenvhelp text anddocs/installation.mdcannot drift apart again.Checked the obvious objection to
Out-String: it does not wrap the 220-charcompleter line even at host width 80, so nothing is truncated.
Why CI missed it
e2e/run.gosourced shellenv through a harness-only variant that pre-joined thelines, so the PowerShell legs exercised an invocation no user is ever told to
write while the shipped one stayed broken and green.
$env:WT_BIN).previously a stray
MSYSTEM/SHELLcould have made it auto-detect bash andfeed bash code into
Invoke-Expression.TestPowerShellSetupLineHasNoDriftpinsdocs/installation.mdande2e/run.goto the constant and fails if either regresses to thesubexpression form. I verified the guard actually fires by reintroducing the
old line in a scratch copy.
Verification
Dispatched CI on this branch before opening the PR: run 32257055607 — all green.
The
E2E (windows, powershell)leg is Windows PowerShell 5.1, the environmentfrom the issue: 77 scenarios passed, 0 failed. Those scenarios assert
cwd_ends_with, which only passes if thewtfunction performedSet-Location—wt.exealone cannot change its parent shell's directory. Sothis is real evidence the integration loaded, not the false pass the issue
warned about.
Known gap, not addressed here
The five PowerShell PTY tests in
cmd/e2e_interactive_test.goare aligned tothe documented form too, but they never run in CI: they are guarded by
testing.Short()and both unit-test jobs rungo test -short. Worth a separateissue; out of scope for this fix. The real coverage comes from
e2e/run.go.