From 2d3289fbc5e48e71d93c3bd7d4299bbc20f726dd Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Sat, 27 Jun 2026 09:02:08 +0800 Subject: [PATCH] fix(installer): resolve local macOS patcher after cwd changes --- scripts/setup-ai-workspace-all-in-one.sh | 5 ++--- tests/setup-ai-workspace-all-in-one-test.sh | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/setup-ai-workspace-all-in-one.sh b/scripts/setup-ai-workspace-all-in-one.sh index 7e54971..e4384e0 100755 --- a/scripts/setup-ai-workspace-all-in-one.sh +++ b/scripts/setup-ai-workspace-all-in-one.sh @@ -1085,9 +1085,8 @@ patch_playbooks_for_macos() { info "Fetching and running macOS playbook patches..." local patch_script="/tmp/patch-macos-playbooks.py" local raw_url="https://raw.githubusercontent.com/ai-workspace-lab/xworkspace-console/main/scripts/patch-macos-playbooks.py" - local bootstrap_script_dir local_patch_script - bootstrap_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" 2>/dev/null && pwd || true)" - local_patch_script="${bootstrap_script_dir}/patch-macos-playbooks.py" + local local_patch_script + local_patch_script="${XWORKSPACE_CONSOLE_DIR}/scripts/patch-macos-playbooks.py" if [ -f "$local_patch_script" ]; then cp "$local_patch_script" "$patch_script" diff --git a/tests/setup-ai-workspace-all-in-one-test.sh b/tests/setup-ai-workspace-all-in-one-test.sh index c7177d8..cf17aba 100755 --- a/tests/setup-ai-workspace-all-in-one-test.sh +++ b/tests/setup-ai-workspace-all-in-one-test.sh @@ -251,8 +251,22 @@ test_macos_plugin_patch_uses_stable_directory() { } test_local_bootstrap_prefers_local_macos_patcher() { - grep -Fq 'if [ -f "$local_patch_script" ]' "$BOOTSTRAP" || - fail "local bootstrap does not prefer its checked-in macOS patcher" + local checkout workdir + checkout="$(mktemp -d)" + workdir="$(mktemp -d)" + mkdir -p "$checkout/scripts" + printf 'local-patcher-marker\n' > "$checkout/scripts/patch-macos-playbooks.py" + ( + XWORKSPACE_CONSOLE_DIR="$checkout" + cd "$workdir" + # shellcheck disable=SC2329 + python3() { + grep -q '^local-patcher-marker$' "$1" || + fail "patch function did not execute the checked-in patcher" + } + patch_playbooks_for_macos + ) + rm -rf "$checkout" "$workdir" grep -Fq '"${raw_url}?rev=$(date +%s)"' "$BOOTSTRAP" || fail "remote macOS patcher download is not cache-busted" }