Skip to content

Lifecycle scripts fail silently on Windows (cmd.exe receives bash flags) #1688

@arthurwyb

Description

@arthurwyb

Bug Description

Lifecycle scripts (setup, run, teardown, stop) configured in .emdash.json fail silently on Windows. The scripts never execute, no error is shown to the user, and the setup tracking window remains empty.

Root Cause

In ptyManager.ts, startLifecyclePty() spawns lifecycle scripts with Unix shell flags:

const proc = pty.spawn(defaultShell, ['-ilc', command], { ... })

On Windows, defaultShell resolves to cmd.exe (via ComSpec), which does not understand the -ilc flags (these are bash/sh flags for interactive, login, command). The command is silently ignored by cmd.exe.

In contrast, the regular agent terminal (startPty()) correctly handles Windows via resolveWindowsPtySpawn(), which wraps commands with cmd.exe /d /s /c flags. This function is not used for lifecycle scripts.

Steps to Reproduce

  1. On Windows, create a project with .emdash.json:
  2. {
  3. "scripts": {
  4. "setup": "echo hello"
    
  5. }
  6. }
  7. 
    
    1. Create a new task
    2. Observe that "echo hello" never executes — no output in the setup tracking window

Expected Behavior

The setup script should execute and show "hello" in the setup tracking output.

Suggested Fix

Apply the same Windows shell handling (resolveWindowsPtySpawn() or equivalent) to startLifecyclePty() so that lifecycle scripts work correctly with cmd.exe on Windows.

Workaround

Use shellSetup instead of scripts.setup, since shellSetup runs in the agent terminal which has proper Windows support:

{
  "shellSetup": "C:\\PROGRA~1\\Git\\bin\\bash.exe -l .emdash/setup.sh"
}

Environment

  • OS: Windows 11 (build 26200.8037)
    • Default shell: cmd.exe (ComSpec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions