Skip to content

Solution to PowerShell on Windows in Letta Code #1273

@waynemerry

Description

@waynemerry

Letta Code git bash patch — what we did and why
───────────────────────────────
The Problem
On Windows, Letta Code's RunShellCommand tool defaults to PowerShell or cmd.exe when spawning shells. This caused several friction points on our dev setup:

  • HEREDOC syntax (<< 'EOF') doesn't work in PowerShell/cmd
  • Bare & operators aren't valid in PowerShell
  • Unix path conventions (/c/Users/...) don't work in cmd
  • Our Docker commands, pytest invocations, and git operations all assume a Unix-style shell
  • We run Git Bash (MINGW64) as our primary terminal and wanted Letta Code to use it too
    ───────────────────────────────
    The Patch
    We patched letta.js directly at:
    C:\Users<USER>\AppData\Roaming\npm\node_modules@letta-ai\letta-code\letta.js
    Inside the windowsLaunchers() function, which controls what shell is tried first when executing a command on Windows, we added a GIT_BASH_PATH override block before the PowerShell fallback:
    // GIT_BASH_PATH patch
    const gitBash = process.env.GIT_BASH_PATH || "";
    if (gitBash) {
    pushUnique(launchers, seen, [gitBash, "-c", trimmed]);
    }
    The original code tried powershell.exe first, then pwsh, then cmd.exe. Our patch inserts Git Bash at position 0 of the launcher list when the GIT_BASH_PATH environment variable is set. If it's not set,
    behaviour is identical to stock — making the patch safely opt-in.
    then sets in his shell environment:
    GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe
    ───────────────────────────────
    Benefits in Letta Code Sessions
    Once the patch was applied, the improvement was immediate and substantial:
  1. All Unix commands work natively — grep, ls, cp, rm, find, cat, wc, sed, awk all execute without Windows-specific workarounds
  2. Docker commands work — docker exec, docker-compose run exactly as they would on Linux
  3. Git commands work fully — git diff, git log, git status with full output, including pipes
  4. Path conventions unified — /c/doc/Programming/... paths work, removing the friction of translating between Windows and Unix path formats
  5. Parallel tool calls work reliably — the & operator for backgrounding is valid in bash; PowerShell's & has different semantics that caused issues
  6. Script portability — management commands, pytest runs, and the rlm skill all use standard bash syntax that now executes without modification
  7. PYTHONIOENCODING and other env var patterns — work as expected in bash; in cmd/PowerShell they require different syntax
    The patch is minimal, non-breaking (opt-in via env var), and survives the Letta Code session — though it needs to be reapplied after npm updates the @letta-ai/letta-code package. We've documented this
    in session memory so we remember to re-patch after upgrades.

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