fix(coding-agent): run %%bash cells in Git Bash on Windows, not WSL bash - #842
fix(coding-agent): run %%bash cells in Git Bash on Windows, not WSL bash#842FiveTechSoft wants to merge 1 commit into
Conversation
On Windows, a bare %%bash cell resolves "bash" through CreateProcess, which finds C:\Windows\System32\bash.exe (WSL) before anything on PATH. Inside WSL there is no Git Credential Manager, so git push blocks on a username/password prompt that the kernel (no TTY, allow_stdin false) can never answer: the cell hangs until the user aborts and the kernel can die with it. Observed in a real session as a 3-minute hang on git push, with commits authored as root@<host>.localdomain (WSL). - Rewrite bare %%bash cells to %%script <Git Bash> by default on Windows via getWindowsIpythonBashScriptPath(); an explicit shellPath still wins. Git Bash is located in the standard install dirs or derived from git.exe on PATH, and converted to its 8.3 short path with forward slashes (C:/PROGRA~1/Git/bin/bash.exe): IPython parses %%script lines on Windows with shlex in non-posix mode, which keeps quotes literally and mangles backslash escapes, so only a space-free forward-slash path survives parsing. - Default the kernel env to GIT_TERMINAL_PROMPT=0 so git fails fast with a clear error instead of hanging forever when no credential helper can answer; an explicit host or per-kernel value still wins.
|
Validated the integration on Windows 11 x64 with Git for Windows:
When combined with #744, the IPython path should remain the public Git Bash launcher, while daemon Job Object execution should retain #744's direct |
|
Hi, thanks for taking the time to contribute to Prime Agent! Since open sourcing the project, we’ve received far more pull requests than we can responsibly review and validate. Prime Agent runs directly on users’ machines, so we need to be deliberate about which changes we accept and how they are reviewed. Rather than leave a large backlog that we cannot meaningfully work through, we’re closing the current PR queue and moving to a discussion-first contribution process. We have established new contribution guidelines to help us continue iterating on Prime Agent and better manage contributions from the community. Going forward, we won’t review unsolicited pull requests. Instead, please start with a GitHub Discussion. We’ll identify recurring bugs and feature requests, create Issues for work we want to pursue, and invite pull requests from maintainers or vouched contributors when implementation is ready. Please read the full process documented in our contribution guidelines. While we’re closing this backlog, we’re still reviewing it at a high level to identify recurring bugs, useful ideas, and important problems that we should address ourselves. Thanks again for the time you put into this! |
Problem
On Windows, a bare
%%bashcell in the IPython kernel resolvesbashthrough CreateProcess, which findsC:\Windows\System32\bash.exe(WSL) before anything on PATH — even when Git Bash is installed and earlier in PATH.Inside WSL there is no Git Credential Manager, so
git push(or any command that prompts) blocks on a username/password prompt that the kernel can never answer — the kernel runs withallow_stdin: falseand no TTY. The cell hangs until the user aborts, and the kernel can die with it. Observed in a real session as a 3-minute hang ongit push, with commits authored asroot@<host>.localdomain(the WSL default identity).Fix
%%bashcells are rewritten to%%script <Git Bash>by default on Windows via a newgetWindowsIpythonBashScriptPath()helper (utils/shell.ts). An explicitshellPathsetting still wins. Git Bash is located in the standard install dirs or derived fromgit.exeon PATH.C:/PROGRA~1/Git/bin/bash.exe). This is required because IPython parses%%scriptlines on Windows with shlex in non-posix mode, which keeps quotes literally and mangles backslash escapes — verified against the installed IPython: only a space-free, forward-slash path survives parsing (quoteScriptMagicArgumentnow also keeps~unquoted for this).GIT_TERMINAL_PROMPT=0(kernel/index.ts): when no credential helper can answer, git fails fast with a clear error instead of hanging the cell forever. An explicit host or per-kernel value still takes precedence.Verification
ipython-provisioner.test.ts(Windows default applied, explicitshellPathwins, no Git Bash → cell untouched). They fail against the old code and pass with the fix.arg_split+create_subprocess_exec+ cell via stdin): runs Git Bash (/mingw64/bin/git,credential.helper=manager) and agit ls-remoteto a nonexistent repo authenticates via GCM and fails fast in ~2s — no hang.npm run check(biome + tsgo + installer + browser-smoke) passes. The 6 remaining test failures on Windows (fake-python sh stubs, chmod-based EACCES) are pre-existing on main and unrelated.Note
Fix
%%bashcells to use Git Bash on Windows instead of WSL bash%%bashcells (with no explicit shell arguments) are rewritten to%%scriptinvocations using a resolved Git Bash path via the newgetWindowsIpythonBashScriptPath()helper inutils/shell.ts.bash.exerelative to anygit.exefound on PATH, replacing previously hardcoded paths.%%scriptargument parser;~is also left unquoted to prevent corruption of Windows short paths.GIT_TERMINAL_PROMPT=0across both forked and directly spawned code paths.%%bashcells will run in Git Bash instead of WSL bash when Git Bash is available; cells are left unchanged if no suitable path is found.Macroscope summarized 3bbe038.