Skip to content

fix(installer): make engram stop script exit 0 on clean Windows install#935

Open
hansell82 wants to merge 1 commit into
Gentleman-Programming:mainfrom
hansell82:fix/engram-stop-exit-code-windows
Open

fix(installer): make engram stop script exit 0 on clean Windows install#935
hansell82 wants to merge 1 commit into
Gentleman-Programming:mainfrom
hansell82:fix/engram-stop-exit-code-windows

Conversation

@hansell82

@hansell82 hansell82 commented Jun 19, 2026

Copy link
Copy Markdown

Summary

On a clean Windows install (no engram process running), gentle-ai install
aborts before configuring any agent:

Error: execute install pipeline: download engram binary:
stop running engram processes before upgrade:
powershell Stop-Process engram: exit status 1 (output: )

Because engram is auto-added as a dependency of every agent install, this
blocks the installer entirely on Windows — even --components skills pulls it in.

Root cause

engramStopScript() (in internal/components/engram/download.go) begins with:

$procs = Get-Process -Name engram -ErrorAction SilentlyContinue
if ($procs) { ... }

On Windows PowerShell 5.1, when no process matches, the suppressed error
still sets $? to $false. The if ($procs) guard is skipped and does not
reset $?, so the script's final automatic status is failure and
powershell.exe -NoProfile -NonInteractive -Command <script> exits 1 with empty
output. stopEngramProcesses() treats any non-zero exit as fatal and aborts the
whole pipeline.

This is the same clean-install regression class as #815 / #919. Those fixes added
the if ($procs) pipeline guard, but the trailing exit code still leaks on a
clean no-op.

Minimal reproduction (Windows PowerShell 5.1)

powershell.exe -NoProfile -NonInteractive -Command '$procs = Get-Process -Name engram -ErrorAction SilentlyContinue; if ($procs) { $procs | Stop-Process -Force -ErrorAction SilentlyContinue }'
echo $LASTEXITCODE   # => 1  (no engram running)

Fix

Append exit 0 to the script. The stop step is best-effort — every call already
uses -ErrorAction SilentlyContinue, and the WARNING: surfacing path (parsed
from stdout by stopEngramProcesses) is unchanged — so forcing a success exit on
a clean no-op is correct.

powershell.exe -NoProfile -NonInteractive -Command '$procs = Get-Process -Name engram -ErrorAction SilentlyContinue; if ($procs) { $procs | Stop-Process -Force -ErrorAction SilentlyContinue }; exit 0'
echo $LASTEXITCODE   # => 0

Verification

Built from this branch on Windows 11 / PowerShell 5.1 and ran
gentle-ai install --agents claude-code --scope global — install now completes
with 65/65 verification checks passing (engram, gga, SDD, skills, theme).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved stop script reliability by ensuring successful completion with proper exit code handling.

On a clean Windows install with no engram process running, `gentle-ai install`
aborts with:

  Error: execute install pipeline: download engram binary:
  stop running engram processes before upgrade:
  powershell Stop-Process engram: exit status 1 (output: )

Root cause: engramStopScript() starts with

  $procs = Get-Process -Name engram -ErrorAction SilentlyContinue

On Windows PowerShell 5.1, when no process matches, the suppressed error still
sets `$?` to $false. The `if ($procs)` guard never runs and does not reset `$?`,
so the script's final state is failure and `powershell.exe -Command` exits 1.
stopEngramProcesses() treats that non-zero exit as fatal, aborting the whole
pipeline. This is the same clean-install regression class as Gentleman-Programming#815 / Gentleman-Programming#919: those
guarded the Stop-Process pipeline, but the trailing exit code still leaks.

Fix: append `exit 0` to the script. The stop step is best-effort (all calls use
-ErrorAction SilentlyContinue) and the WARNING surfacing path is unchanged, so
forcing a success exit on a clean no-op is correct.

Verified on Windows 11 / PowerShell 5.1: built from this branch and
`gentle-ai install --agents claude-code` now completes (65/65 checks).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 427f2783-029f-4bdf-94ee-461f7333aa6f

📥 Commits

Reviewing files that changed from the base of the PR and between 0a9ffdd and aa41ac6.

📒 Files selected for processing (1)
  • internal/components/engram/download.go

📝 Walkthrough

Walkthrough

engramStopScript() in internal/components/engram/download.go is updated to append an explicit exit 0 line to the generated PowerShell stop script, ensuring the script exits with a success status code after attempting to stop any running engram processes.

Changes

engram PowerShell stop script exit code

Layer / File(s) Summary
Append exit 0 to stop script
internal/components/engram/download.go
Adds exit 0 to the end of the PowerShell script returned by engramStopScript(), so the script always reports a success exit code to its caller after executing the stop logic.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

Suggested labels

type:bug, size:exception

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: making the engram stop script exit with code 0 on clean Windows installations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant