orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: Worktree "Local setup command" is built as a cmd.exe invocation on Windows — fails to run under the configured Git Bash shell

Open VWforEI opened this issue 5 months ago • 1 comments

Operating system

Windows

Orca version

1.4.110

Details

Environment

  • Orca 1.4.110
  • Windows 11 (10.0.26200)
  • Default terminal shell: Git Bash (terminalWindowsShell: "git-bash")

Summary

When a worktree is created, the interactive terminal correctly opens in Git Bash (my configured shell). However, the Local setup command is built as a Windows cmd invocation (cmd.exe /c "orca/setup-runner.cmd") and sent into that Git Bash terminal, ignoring the configured shell. This fails in two ways at once: (1) the runner is a cmd batch file, so setup commands written in shell syntax can't run; and (2) the cmd.exe /c ... launch line itself is mangled by Git Bash's path conversion, so it never actually executes.

Repro

  1. Set default Windows shell to Git Bash.
  2. Configure a worktree Local setup command using POSIX syntax:
    cp ~/Documents/test/.env.local .env.local
    pnpm install
    
  3. Create a new worktree.

Expected

The setup command runs in the configured shell (Git Bash), so cp and ~ work.

Actual

The Git Bash terminal launches but immediately shells out to cmd, and the setup never runs:

$ cmd.exe /c "C:/Users/VW/Documents/test/.git/worktrees/<wt>/orca/setup-runner.cmd"
Microsoft Windows [Version 10.0.26200.8737]
(c) Microsoft Corporation. All rights reserved.

C:\Users\VW\orca\workspaces\test\<wt>>

Two distinct failures, same root cause:

1. The runner does not execute at all. The command cmd.exe /c "<path>" is sent into a Git Bash shell, but Git Bash's MSYS path conversion rewrites the /c argument into a Windows path. cmd.exe therefore never receives the /c switch and opens interactively (hence the version banner and the empty C:\...> prompt) instead of running the runner. Reproduced directly in Git Bash:

$ cmd.exe /c "echo HELLO"
Microsoft Windows [Version 10.0.26200.8737]
(c) Microsoft Corporation. All rights reserved.

C:\Users\VW\Documents\test>          # "HELLO" never prints; interactive cmd opens

# git-bash-safe forms both work:
$ cmd.exe //c "echo HELLO"           # -> HELLO
$ MSYS_NO_PATHCONV=1 cmd.exe /c "echo HELLO"   # -> HELLO

2. Even if it ran, the runner is cmd batch and can't execute the shell script. The generated setup-runner.cmd:

@echo off
setlocal EnableExtensions
call cp ~/Documents/test/.env.local .env.local
if errorlevel 1 exit /b %errorlevel%
call pnpm install
if errorlevel 1 exit /b %errorlevel%

cp/~ are not valid in cmd, so the setup would fail regardless.

Root cause (from app.asar)

  • createRemoteSetupRunnerScript selects orca/setup-runner.cmd based only on isWindowsAbsolutePathLike(worktreePath) — not on the configured shell.
  • buildWindowsRunnerScript always emits a cmd batch wrapper (call <line>).
  • resolveSetupRunnerCommand builds the launch string as cmd.exe /c <runnerScriptPath> (again keyed on isWindowsAbsolutePathLike(runnerScriptPath)), which is then run inside the Git Bash terminal where /c gets path-mangled.

The setup-runner format and its launch command should follow terminalWindowsShell (e.g. emit setup-runner.sh and run it via bash when the shell is git-bash), rather than being hardcoded to cmd on Windows. If a cmd invocation must be issued from a POSIX shell, it needs //c (or MSYS_NO_PATHCONV=1) so the switch survives path conversion.

VWforEI avatar Jun 30 '26 12:06 VWforEI

Agent reproduction package (Windows orchestration 2026-07-16)

Host context: Windows 11 / Orca 1.4.143.0 / repo path used: docs/bug-reproductions/
Labels applied: see issue labels (has_repro or cannot_repro).
Security: Do not run user-uploaded binaries from issue attachments. Recreate fixtures from the steps/scripts below.


Issue 6896 — Local setup command as cmd.exe under Git Bash

Status: repro_confirmed (MSYS path-conversion half)
Host: Windows 11, Git Bash C:\Program Files\Git\bin\bash.exe
Label: has_repro

Summary

When Orca emits cmd.exe /c "...", and that line is executed inside Git Bash, MSYS path conversion rewrites /c into a Windows path. cmd.exe never receives the /c switch, opens interactively, and does not run the payload. This matches half of the issue (setup-runner never executes under Git Bash). The second half (setup-runner.cmd cannot run POSIX shell syntax) is design/source-level and needs Orca UI worktree setup to demonstrate end-to-end.

Repro (another agent)

powershell -NoProfile -ExecutionPolicy Bypass -File docs/bug-reproductions/scripts/repro-6896-gitbash-cmd-pathconv.ps1
# Expect exit 0

Manual:

# In Git Bash — broken (interactive cmd, no HELLO):
cmd.exe /c "echo HELLO"

# Workarounds:
cmd.exe //c "echo HELLO"
MSYS_NO_PATHCONV=1 cmd.exe /c "echo HELLO"

Evidence

  • docs/bug-reproductions/evidence/6896-20260716-021230.json
  • Broken form printed Microsoft Windows [Version ...] interactive banner and prompt; no HELLO

Expected vs actual

Expected Setup runner executes under configured shell (Git Bash)
Actual cmd.exe /c becomes interactive; setup never runs

Orca source linkage

Search setup-runner.cmd, createSetupRunnerScript, buildWindowsSetupCommand in src/shared / src/main/hooks*.

Repro script: repro-6896-gitbash-cmd-pathconv.ps1

# Repro for https://github.com/stablyai/orca/issues/6896
# Git Bash MSYS path conversion rewrites `cmd.exe /c` into interactive cmd.
#
# Usage:
#   powershell -NoProfile -ExecutionPolicy Bypass -File docs/bug-reproductions/scripts/repro-6896-gitbash-cmd-pathconv.ps1
#
# Exit 0 = bug reproduced (cmd /c does not run payload under bash).
# Exit 2 = not reproduced.

$ErrorActionPreference = 'Stop'
$evidenceDir = Join-Path (Split-Path $PSScriptRoot -Parent) 'evidence'
New-Item -ItemType Directory -Force -Path $evidenceDir | Out-Null
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$log = Join-Path $evidenceDir "6896-$stamp.log"
function Log($m) { $l = "[$(Get-Date -Format o)] $m"; Add-Content $log $l; Write-Host $l }

$bash = @(
  'C:\Program Files\Git\bin\bash.exe',
  'C:\Program Files\Git\usr\bin\bash.exe'
) | Where-Object { Test-Path $_ } | Select-Object -First 1

if (-not $bash) {
  Log 'Git Bash not found — cannot run 6896 repro'
  exit 1
}

Log "=== Issue 6896: Git Bash path-converts cmd.exe /c ==="
Log "bash=$bash"

function Run-Bash([string]$script) {
  $out = & $bash -lc $script 2>&1 | Out-String
  return @{ exit = $LASTEXITCODE; out = $out }
}

# Issue demo: /c rewritten so cmd opens interactively and never echoes HELLO.
# Use timeout-ish: cmd with no further input would hang if interactive.
# Prefer `//c` and MSYS_NO_PATHCONV forms as positive controls with short commands.

# Use single-quoted bash -lc payloads so PowerShell does not eat quotes.
$broken = Run-Bash 'cmd.exe /c "echo HELLO_6896" </dev/null; printf "EXIT:%s\n" $?'
Log "BROKEN form output:`n$($broken.out)"

$fixedDoubleSlash = Run-Bash 'cmd.exe //c "echo HELLO_6896"; printf "EXIT:%s\n" $?'
Log "FIXED //c form:`n$($fixedDoubleSlash.out)"

$fixedNoPathConv = Run-Bash 'MSYS_NO_PATHCONV=1 cmd.exe /c "echo HELLO_6896"; printf "EXIT:%s\n" $?'
Log "FIXED MSYS_NO_PATHCONV form:`n$($fixedNoPathConv.out)"

$brokenHasHello = $broken.out -match 'HELLO_6896'
$fixedDoubleOk = $fixedDoubleSlash.out -match 'HELLO_6896'
$fixedNoPathOk = $fixedNoPathConv.out -match 'HELLO_6896'
$fixedHasHello = $fixedDoubleOk -or $fixedNoPathOk
# Interactive banner is the classic signal that /c was path-converted away
$brokenLooksInteractive = $broken.out -match 'Microsoft Windows'

# Bug is reproduced when plain /c fails to run the payload (no HELLO) and
# typically shows the interactive Windows banner; positive controls optional.
$reproduced = (-not $brokenHasHello) -and $brokenLooksInteractive

$result = [ordered]@{
  issue = 6896
  stamp = $stamp
  bash = $bash
  brokenHasHello = $brokenHasHello
  brokenLooksInteractive = $brokenLooksInteractive
  fixedHasHello = $fixedHasHello
  bugReproduced = $reproduced
  brokenOut = $broken.out
  fixedDoubleSlashOut = $fixedDoubleSlash.out
  fixedNoPathConvOut = $fixedNoPathConv.out
  log = $log
}
$json = Join-Path $evidenceDir "6896-$stamp.json"
$result | ConvertTo-Json -Depth 5 | Set-Content $json -Encoding utf8
Log "Wrote $json bugReproduced=$reproduced"

# Second half of issue: Orca emits cmd.exe /c setup-runner.cmd for wait-for-setup / setup runner.
# Document string pattern from source (no import needed).
Log 'Source pattern: setup-agent-sequencing + hooks create setup-runner.cmd and wrap with cmd.exe /c'

if ($reproduced) { exit 0 } else { exit 2 }


How another agent should use this

  1. Read this comment fully (status, expected vs actual, blockers).
  2. If a script is included above, copy it to a temp file and run it on a Windows 11 host with Orca installed (prefer production install under %LOCALAPPDATA%\Programs\orca).
  3. Capture evidence (CLI --json, screenshots, logs) under a local folder; optionally comment results back here.
  4. If status is cannot_repro / needs_setup, satisfy the listed prerequisites first, then re-attempt and flip labels: remove cannot_repro, add has_repro when conclusive.

OrcaWin avatar Jul 17 '26 00:07 OrcaWin