From b159aa2c502cbaa49ef8e65f79c116c9abedbff2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 13:04:09 +0000 Subject: [PATCH 1/4] Initial plan From e3d7da5e6e4511016df58d13d6aae36cf246e9d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 13:10:02 +0000 Subject: [PATCH 2/4] fix: capture brew/mas install output via temp file to avoid broken pipe on WSL/Debian --- .../run_onchange_10-install-packages.sh.tmpl | 24 ++++++++++++++----- tests/bash/test-chezmoi-scripts.bats | 8 +++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl b/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl index efbfadef..9e7afb5b 100644 --- a/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl +++ b/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl @@ -26,12 +26,18 @@ brew_install_quiet() { return 0 fi log_step "Installing $pkg" - if output=$(brew install "$pkg" 2>&1); then + # Redirect brew output to a temp file rather than capturing it through a + # command-substitution pipe. Homebrew's concurrent output can raise + # "Error: Broken pipe" (SIGPIPE) when its stdout is a pipe rather than a + # TTY or regular file, which was breaking installs on WSL/Debian. + brew_log=$(mktemp) + if brew install "$pkg" >"$brew_log" 2>&1; then log_result "Installed $pkg" else log_warn "Failed to install $pkg" - printf '%s\n' "$output" | log_data WARN "brew output" + log_data WARN "brew output" <"$brew_log" fi + rm -f "$brew_log" } # Helper: install a Homebrew cask (GUI application) quietly, mirroring @@ -43,12 +49,15 @@ brew_install_cask_quiet() { return 0 fi log_step "Installing $pkg (cask)" - if output=$(brew install --cask "$pkg" 2>&1); then + # See brew_install_quiet: redirect to a file to avoid SIGPIPE/"Broken pipe". + brew_log=$(mktemp) + if brew install --cask "$pkg" >"$brew_log" 2>&1; then log_result "Installed $pkg (cask)" else log_warn "Failed to install $pkg (cask)" - printf '%s\n' "$output" | log_data WARN "brew output" + log_data WARN "brew output" <"$brew_log" fi + rm -f "$brew_log" } # Helper: install a Mac App Store app via `mas`. Requires the `mas` formula @@ -66,12 +75,15 @@ mas_install_quiet() { return 0 fi log_step "Installing $app_name ($app_id)" - if output=$(mas install "$app_id" 2>&1); then + # See brew_install_quiet: redirect to a file to avoid SIGPIPE/"Broken pipe". + mas_log=$(mktemp) + if mas install "$app_id" >"$mas_log" 2>&1; then log_result "Installed $app_name ($app_id)" else log_warn "Failed to install $app_name ($app_id)" - printf '%s\n' "$output" | log_data WARN "mas output" + log_data WARN "mas output" <"$mas_log" fi + rm -f "$mas_log" } # Check if running with sudo privileges diff --git a/tests/bash/test-chezmoi-scripts.bats b/tests/bash/test-chezmoi-scripts.bats index e7ec4b5f..61340c1c 100644 --- a/tests/bash/test-chezmoi-scripts.bats +++ b/tests/bash/test-chezmoi-scripts.bats @@ -176,6 +176,14 @@ strip_template() { grep -q 'index .packages.darwin.brew "app-store"' "$script" } +@test "chezmoi-scripts: install-packages captures brew output via temp file (avoids broken pipe)" { + local script="$LINUX_SCRIPTS_DIR/run_onchange_10-install-packages.sh.tmpl" + # Output must be redirected to a file, not captured through a + # command-substitution pipe (which triggers Homebrew "Broken pipe" on WSL). + grep -q 'brew install "\$pkg" >"\$brew_log" 2>&1' "$script" + ! grep -q 'output=\$(brew install' "$script" +} + @test "chezmoi-scripts: install-packages references nested darwin brew formulas" { local script="$LINUX_SCRIPTS_DIR/run_onchange_10-install-packages.sh.tmpl" grep -q '\.packages\.darwin\.brew\.formulas\.' "$script" From 051535d507b816069b37a060ba54eff1adf3a4e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:06:23 +0000 Subject: [PATCH 3/4] fix: add jdx.mise to Windows winget full packages to fix CI test --- home/.chezmoidata/packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.chezmoidata/packages.yaml b/home/.chezmoidata/packages.yaml index ffe4da22..33887b70 100644 --- a/home/.chezmoidata/packages.yaml +++ b/home/.chezmoidata/packages.yaml @@ -126,6 +126,7 @@ packages: - twpayne.chezmoi full: - Fastfetch-cli.Fastfetch + - jdx.mise - Microsoft.VisualStudioCode - JanDeDobbeleer.OhMyPosh - Microsoft.WSL From b45879d2eed9d28baecb9d1bfd7c5e34c244e815 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:08:42 +0000 Subject: [PATCH 4/4] fix: use trap RETURN to ensure brew/mas temp files are always cleaned up --- .../linux/run_onchange_10-install-packages.sh.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl b/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl index 9e7afb5b..8482db5d 100644 --- a/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl +++ b/home/.chezmoiscripts/linux/run_onchange_10-install-packages.sh.tmpl @@ -31,13 +31,13 @@ brew_install_quiet() { # "Error: Broken pipe" (SIGPIPE) when its stdout is a pipe rather than a # TTY or regular file, which was breaking installs on WSL/Debian. brew_log=$(mktemp) + trap 'rm -f "$brew_log"' RETURN if brew install "$pkg" >"$brew_log" 2>&1; then log_result "Installed $pkg" else log_warn "Failed to install $pkg" log_data WARN "brew output" <"$brew_log" fi - rm -f "$brew_log" } # Helper: install a Homebrew cask (GUI application) quietly, mirroring @@ -51,13 +51,13 @@ brew_install_cask_quiet() { log_step "Installing $pkg (cask)" # See brew_install_quiet: redirect to a file to avoid SIGPIPE/"Broken pipe". brew_log=$(mktemp) + trap 'rm -f "$brew_log"' RETURN if brew install --cask "$pkg" >"$brew_log" 2>&1; then log_result "Installed $pkg (cask)" else log_warn "Failed to install $pkg (cask)" log_data WARN "brew output" <"$brew_log" fi - rm -f "$brew_log" } # Helper: install a Mac App Store app via `mas`. Requires the `mas` formula @@ -77,13 +77,13 @@ mas_install_quiet() { log_step "Installing $app_name ($app_id)" # See brew_install_quiet: redirect to a file to avoid SIGPIPE/"Broken pipe". mas_log=$(mktemp) + trap 'rm -f "$mas_log"' RETURN if mas install "$app_id" >"$mas_log" 2>&1; then log_result "Installed $app_name ($app_id)" else log_warn "Failed to install $app_name ($app_id)" log_data WARN "mas output" <"$mas_log" fi - rm -f "$mas_log" } # Check if running with sudo privileges