fix(BUG-021+BUG-022): pre-export DOTFILES_REPO_DIR + race-free healthcheck probe (cross-OS)#87
Merged
Conversation
…check probe (cross-OS) Two micro-fixes surfaced by user's post-merge setup run: ## BUG-021: doctor + diff-check warn/fail when profile hasn't reloaded BUG-020 (PR #86) added the DOTFILES_REPO_DIR export to profile.ps1 + .bashrc + .zshrc, but the shell already running setup has the OLD profile loaded in memory. doctor + diff-check (invoked by healthcheck sec 12) see the var unset until the user opens a fresh shell. Fix: pre-export DOTFILES_REPO_DIR in setup-{windows.ps1,linux.sh} RIGHT BEFORE invoking doctor/healthcheck. Same pre-export pattern as SCRIPTS_DIR / GEMINI_HOME / COPILOT_HOME / OPENCODE_HOME. ## BUG-022: healthcheck BUG-015 probe itself races via `break; }; done` The probe added by BUG-015 (PR #81) to detect upstream hook resolution failures uses the SAME `{ printf; ls; printf; } | while ... break` cascade pattern that BUG-017 patched in the upstream hooks themselves. The probe hits the EPIPE race when invoked from Windows pwsh-spawned bash (Git Bash subprocess sandbox), reporting false-positive FAIL even when the install is healthy. Fix: apply the same Option A `done | head -n1` to the probe in both healthcheck.sh and healthcheck.ps1. The probe now drains the upstream pipe fully, then head -n1 takes the first match. No EPIPE. Note: on Linux, SIGPIPE is silent so the race rarely fires, but cross-OS parity with the Windows fix matters for consistency. Combined diff: 27 LOC (14 setup-windows.ps1 + 4 setup-linux.sh + 7 healthcheck.ps1 + 9 healthcheck.sh + small minus markers). Below spec-gate threshold (50 LOC). Skip SDD per "mechanical cross-OS mirror" rule. Empirical post-fix behavior: - doctor sec env-vars: 10/10 ok (DOTFILES_REPO_DIR no longer warn) - healthcheck sec 4 BUG-015: PASS reports actual resolved path (no spurious FAIL) - healthcheck sec 12 diff-check: exit 0 or 1 (real drift state), no more exit 2 "setup error" Cross-OS scope justified: setup-linux.sh had the same gap (export block at line 950-954); healthcheck.sh probe had the same race-prone pattern (line 201). Both fixed in this PR to keep cross-OS contract symmetric.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two micro-fixes surfaced by user's post-merge setup-windows.ps1 run output:
```
doctor sec env-vars: [warn] DOTFILES_REPO_DIR unset; default would be applied with -Fix
healthcheck sec 4: FAIL: claude-mem hook path resolution FAILED (BUG-015)
healthcheck sec 12: FAIL: diff-check.ps1 exited with code 2 (setup error)
```
BUG-021: pre-export DOTFILES_REPO_DIR in setup before doctor/healthcheck
BUG-020 (PR #86) added the `DOTFILES_REPO_DIR` export to `profile.ps1` + `.bashrc` + `.zshrc`. But the shell running setup already has the OLD profile loaded — doctor + diff-check see the var unset until next shell restart. Mirror the same pre-export pattern as SCRIPTS_DIR / GEMINI_HOME / etc.
Cross-OS: `setup-linux.sh` line 952-954 had the same gap (pre-exports GEMINI_HOME/COPILOT_HOME/OPENCODE_HOME but not DOTFILES_REPO_DIR). Both setup scripts fixed in this PR.
BUG-022: healthcheck BUG-015 probe races via
break; }; doneThe probe added by BUG-015 (PR #81) uses the SAME race-prone cascade pattern that BUG-017 patched away in the upstream hooks. From Windows pwsh-spawned bash, the EPIPE race fires on the probe itself → spurious FAIL even when the install is healthy. Apply the same Option A `done | head -n1` to make the probe race-free.
Cross-OS: healthcheck.sh probe (line 201) has the same pattern; race is silent on Linux due to SIGPIPE handling but worth fixing for consistency.
Test plan
Diff
```
scripts/healthcheck.ps1 | 7 ++++++-
scripts/healthcheck.sh | 9 +++++++--
setup-linux.sh | 4 ++++
setup-windows.ps1 | 14 ++++++++++----
4 files changed, 27 insertions(+), 7 deletions(-)
```
Below spec-gate threshold (27 LOC). Skip SDD.
Companion