From 5ea7dd95bd5060d0723460c487459ac7020e367a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:08:09 +0000 Subject: [PATCH 01/12] Clean up unmanaged Homebrew taps before doctor Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 480233e..7b224d7 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -403,6 +403,49 @@ update_homebrew() { return 0 } +cleanup_unmanaged_homebrew_taps() { + if ! command_exists brew; then + return 0 + fi + + if [ ! -f "Brewfile" ]; then + return 0 + fi + + local tap required_tap + local -a required_taps installed_taps + + while IFS= read -r tap; do + if [ -n "$tap" ]; then + required_taps+=("$tap") + fi + done < <(sed -n 's/^tap[[:space:]]*"\([^"]*\)".*/\1/p' Brewfile) + + while IFS= read -r tap; do + if [ -n "$tap" ]; then + installed_taps+=("$tap") + fi + done < <(brew tap 2>/dev/null) + + for tap in "${installed_taps[@]}"; do + local keep_tap=false + for required_tap in "${required_taps[@]}"; do + if [ "$tap" = "$required_tap" ]; then + keep_tap=true + break + fi + done + + if [ "$keep_tap" = true ]; then + continue + fi + + brew untap "$tap" >/dev/null 2>&1 || true + done + + return 0 +} + install_brewfile() { echo "Installing packages and applications from Brewfile..." local brew_bundle_args=(--verbose) @@ -667,6 +710,8 @@ run_post_checks() { return 1 fi + cleanup_unmanaged_homebrew_taps + if ! invoke_with_retry "Run brew doctor" brew doctor; then if is_ci_environment; then echo "Ignoring brew doctor failure in CI due to hosted-runner Homebrew warnings." From 4320c8fcbd78a834a17644de36cd25c4ef245be4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:08:28 +0000 Subject: [PATCH 02/12] Log warning when untap cleanup fails Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 7b224d7..d594397 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -440,7 +440,9 @@ cleanup_unmanaged_homebrew_taps() { continue fi - brew untap "$tap" >/dev/null 2>&1 || true + if ! brew untap "$tap" >/dev/null 2>&1; then + echo "Warning: Unable to untap $tap; it may still be required by installed formulae." + fi done return 0 From b46fedbf07a2875b41053e2901c9000fb81ba899 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:08:48 +0000 Subject: [PATCH 03/12] Polish tap cleanup diagnostics Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index d594397..ed6f9bf 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -413,6 +413,7 @@ cleanup_unmanaged_homebrew_taps() { fi local tap required_tap + local keep_tap local -a required_taps installed_taps while IFS= read -r tap; do @@ -428,7 +429,7 @@ cleanup_unmanaged_homebrew_taps() { done < <(brew tap 2>/dev/null) for tap in "${installed_taps[@]}"; do - local keep_tap=false + keep_tap=false for required_tap in "${required_taps[@]}"; do if [ "$tap" = "$required_tap" ]; then keep_tap=true @@ -441,7 +442,7 @@ cleanup_unmanaged_homebrew_taps() { fi if ! brew untap "$tap" >/dev/null 2>&1; then - echo "Warning: Unable to untap $tap; it may still be required by installed formulae." + echo "Warning: Unable to untap $tap; it may still be required by installed formulae." >&2 fi done From 63702da227bd1fdafeb12b9ec15a5610ce514ad7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:10:51 +0000 Subject: [PATCH 04/12] Refine Homebrew tap cleanup safeguards Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index ed6f9bf..8190b70 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -408,8 +408,14 @@ cleanup_unmanaged_homebrew_taps() { return 0 fi - if [ ! -f "Brewfile" ]; then - return 0 + local brewfile_path="Brewfile" + if [ ! -f "$brewfile_path" ]; then + local script_dir + script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) + brewfile_path="$script_dir/Brewfile" + if [ ! -f "$brewfile_path" ]; then + return 0 + fi fi local tap required_tap @@ -420,7 +426,7 @@ cleanup_unmanaged_homebrew_taps() { if [ -n "$tap" ]; then required_taps+=("$tap") fi - done < <(sed -n 's/^tap[[:space:]]*"\([^"]*\)".*/\1/p' Brewfile) + done < <(sed -n 's/^tap[[:space:]]*"\([^"]*\)".*/\1/p' "$brewfile_path") while IFS= read -r tap; do if [ -n "$tap" ]; then @@ -441,7 +447,11 @@ cleanup_unmanaged_homebrew_taps() { continue fi - if ! brew untap "$tap" >/dev/null 2>&1; then + if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" != homebrew/* ]]; then + continue + fi + + if ! brew untap "$tap"; then echo "Warning: Unable to untap $tap; it may still be required by installed formulae." >&2 fi done From 9b5876fd024fe122f338ded7ebaa67ac1a57f318 Mon Sep 17 00:00:00 2001 From: Antony Bailey Date: Thu, 10 Sep 2026 09:50:17 +0100 Subject: [PATCH 05/12] Update tap condition to include homebrew/bundle Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- NewMachineSetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 8190b70..72d7377 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -447,7 +447,7 @@ cleanup_unmanaged_homebrew_taps() { continue fi - if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" != homebrew/* ]]; then + if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" != homebrew/* || "$tap" = homebrew/bundle ]]; then continue fi From 83a8a5e9d0b9d7e36354ed3f65b1d2948657fe84 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:04:25 +0000 Subject: [PATCH 06/12] Fix unbound variable error for empty arrays in untap logic (set -u safe) Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 72d7377..2366a7f 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -420,7 +420,7 @@ cleanup_unmanaged_homebrew_taps() { local tap required_tap local keep_tap - local -a required_taps installed_taps + local -a required_taps=() installed_taps=() while IFS= read -r tap; do if [ -n "$tap" ]; then From 54e6180917e82a643a7fe8135667c5af5c420e57 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:05:18 +0000 Subject: [PATCH 07/12] Fix untap guard condition: preserve homebrew/* taps when required_taps is empty Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 2366a7f..9c33a8f 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -447,7 +447,7 @@ cleanup_unmanaged_homebrew_taps() { continue fi - if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" != homebrew/* || "$tap" = homebrew/bundle ]]; then + if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" == homebrew/* ]]; then continue fi From f672612d795a45748c20aa02676dc396f2fd75b9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:05:50 +0000 Subject: [PATCH 08/12] Always preserve homebrew/* taps unconditionally in untap guard Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 9c33a8f..4d7881b 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -447,7 +447,7 @@ cleanup_unmanaged_homebrew_taps() { continue fi - if [ ${#required_taps[@]} -eq 0 ] && [[ "$tap" == homebrew/* ]]; then + if [[ "$tap" == homebrew/* ]]; then continue fi From 446c7bafd2d1e79a33bd4c5e79bf7a679e15b4a9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:06:17 +0000 Subject: [PATCH 09/12] Improve brew untap warning message to be more actionable Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 4d7881b..d467ba5 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -452,7 +452,7 @@ cleanup_unmanaged_homebrew_taps() { fi if ! brew untap "$tap"; then - echo "Warning: Unable to untap $tap; it may still be required by installed formulae." >&2 + echo "Warning: Unable to untap '$tap'. It is likely still required by an installed formula; remove the dependent formula first." >&2 fi done From 554d716db7d02b2fe24c0f09075fce484a15d296 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:22:12 +0000 Subject: [PATCH 10/12] Fix unbound variable error for empty arrays under set -u in brew untap loop Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index d467ba5..e099bee 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -434,9 +434,9 @@ cleanup_unmanaged_homebrew_taps() { fi done < <(brew tap 2>/dev/null) - for tap in "${installed_taps[@]}"; do + for tap in "${installed_taps[@]+"${installed_taps[@]}"}"; do keep_tap=false - for required_tap in "${required_taps[@]}"; do + for required_tap in "${required_taps[@]+"${required_taps[@]}"}"; do if [ "$tap" = "$required_tap" ]; then keep_tap=true break From 4211cd91b76b0a032087e09ba0a5064f8668871b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:22:52 +0000 Subject: [PATCH 11/12] Skip brew.sh network check on CI in preflight validation Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index e099bee..0415068 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -272,8 +272,12 @@ validate_inputs() { for endpoint in "https://brew.sh" "https://pypi.org/simple/" "https://rubygems.org"; do if ! check_url_connectivity "$endpoint"; then - record_failure "preflight-validation" "network_unreachable_$(echo "$endpoint" | sed 's#https\?://##; s#[^A-Za-z0-9]#_#g')" - valid=false + if is_ci_environment && [ "$endpoint" = "https://brew.sh" ]; then + echo "Warning: $endpoint unreachable in CI environment; skipping as non-fatal" + else + record_failure "preflight-validation" "network_unreachable_$(echo "$endpoint" | sed 's#https\?://##; s#[^A-Za-z0-9]#_#g')" + valid=false + fi fi done From 73532e9d98a28b87fdb47738aa4384cf7e2cb138 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 10 Sep 2026 09:23:03 +0000 Subject: [PATCH 12/12] Fix array safe-expansion pattern: remove outer double quotes per bash spec Co-authored-by: PartTimeLegend <791578+PartTimeLegend@users.noreply.github.com> --- NewMachineSetup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewMachineSetup.sh b/NewMachineSetup.sh index 0415068..18074c5 100755 --- a/NewMachineSetup.sh +++ b/NewMachineSetup.sh @@ -438,9 +438,9 @@ cleanup_unmanaged_homebrew_taps() { fi done < <(brew tap 2>/dev/null) - for tap in "${installed_taps[@]+"${installed_taps[@]}"}"; do + for tap in ${installed_taps[@]+"${installed_taps[@]}"}; do keep_tap=false - for required_tap in "${required_taps[@]+"${required_taps[@]}"}"; do + for required_tap in ${required_taps[@]+"${required_taps[@]}"}; do if [ "$tap" = "$required_tap" ]; then keep_tap=true break