fix(BUG-020): export DOTFILES_REPO_DIR in PowerShell profile (cross-OS parity)#86
Merged
Merged
Conversation
…S parity) Empirical: user's post-merge setup-windows.ps1 run reported `FAIL: diff-check.ps1 exited with code 2 (setup error)` in healthcheck sec 12. Tracing showed diff-check.ps1 exits 2 because DOTFILES_REPO_DIR is unset on Windows -- the script falls back to Split-Path $PSScriptRoot which resolves to $env:USERPROFILE\scripts (deploy location, NOT a git repo) and hits the "not a git repo" guard. Linux side (.bashrc + .zshrc) has exported DOTFILES_REPO_DIR since forever (line 49 / line 21 respectively). PowerShell profile was the only one missing it. REFACTOR-003 (PR #82) shipped diff-check.ps1 + wired healthcheck sec 12 to invoke it, surfacing the asymmetry. Changes: 1. powershell/profile.ps1: `$env:DOTFILES_REPO_DIR = "$env:USERPROFILE\Projects\dotfiles"` next to the existing $env:DOTFILES_DIR line, with a comment explaining why. 2. env-contract.json: new entry for DOTFILES_REPO_DIR (required: false since not every consumer needs the repo path -- only diff-check does). doctor.{sh,ps1} now validates it on every run. 3. tests/setup-linux.bats: 2 new asserts -- all 3 profile files export DOTFILES_REPO_DIR; env-contract.json declares it. 37 LOC total (17 prod + 20 test). Below spec-gate threshold. Skip SDD. Empirical post-fix: re-running healthcheck.ps1 sec 12 with the new env var set produces `PASS: No drift between repo and deploy-dir` (or `FAIL: Drift detected` if there is genuine drift, exit code 1). Closes the last "setup error" FAIL surfaced by the post-merge run. Pairs with REFACTOR-003 (PR #82) which introduced the diff-check.ps1 that exposed the gap.
Merged
6 tasks
mlorentedev
added a commit
that referenced
this pull request
May 21, 2026
…check probe (cross-OS) (#87) 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
User's post-merge `setup-windows.ps1` run reported `FAIL: diff-check.ps1 exited with code 2 (setup error)` in healthcheck sec 12 (introduced by REFACTOR-003 PR #82). Tracing: diff-check.ps1 exits 2 because `DOTFILES_REPO_DIR` is unset on Windows — the script falls back to `Split-Path $PSScriptRoot` which resolves to `$env:USERPROFILE\scripts` (deploy location, NOT a git repo) and hits the "not a git repo" guard.
Linux side (.bashrc + .zshrc) has exported `DOTFILES_REPO_DIR` since forever. PowerShell profile was the only one missing it.
Changes
37 LOC total (17 prod + 20 test). Below spec-gate threshold. Skip SDD.
Test plan
Companion