From c259029c0a708d00b07cacd426b80cb4ede56c7b Mon Sep 17 00:00:00 2001 From: Sagar Dagdu Date: Tue, 5 May 2026 10:15:12 +0530 Subject: [PATCH 1/4] fix(bootstrap): detect Xcode installs with non-default app names on macOS Previously script/macos/bootstrap hardcoded /Applications/Xcode.app for both the existence check and the xcode-select --switch call. This rejected valid Xcode installs managed by Xcodes.app (e.g. Xcode-26.3.0.app, Xcode-beta.app) even when xcode-select already pointed at one. Now the script first respects whatever full Xcode developer dir is already selected via xcode-select -p, and only falls back to globbing /Applications/Xcode*.app when the selection is missing or points at the Command Line Tools. The auto-switch is preserved so users with a full Xcode but CLT currently selected don't have to fix selection by hand. Fixes #10125 --- script/macos/bootstrap | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/script/macos/bootstrap b/script/macos/bootstrap index f146e4b1b..d45fd59f9 100755 --- a/script/macos/bootstrap +++ b/script/macos/bootstrap @@ -5,12 +5,15 @@ set -e -if ! [ -d "/Applications/Xcode.app" ]; then - echo "Please install Xcode from the App Store before continuing." - exit 1 +DEVELOPER_DIR="$(xcode-select -p 2>/dev/null || true)" +if [ -z "$DEVELOPER_DIR" ] || [ ! -x "$DEVELOPER_DIR/usr/bin/xcodebuild" ] || [ "$DEVELOPER_DIR" = "/Library/Developer/CommandLineTools" ]; then + XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | head -n 1)" + if [ -z "$XCODE_APP" ]; then + echo "Please install Xcode before continuing." + exit 1 + fi + sudo xcode-select --switch "$XCODE_APP/Contents/Developer" fi - -sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer # Mimic actually launching XCode, which performs some necessary set-up of the # development environment. xcodebuild -runFirstLaunch From dfc50569823c84d28b76b85ff3e9a82a5cc4aced Mon Sep 17 00:00:00 2001 From: Sagar Dagdu Date: Tue, 5 May 2026 10:17:44 +0530 Subject: [PATCH 2/4] fix(bootstrap): validate xcodebuild presence per Xcode candidate The previous fallback picked the first /Applications/Xcode*.app alphabetically, which would incorrectly select /Applications/Xcodes.app (the Xcodes installer/launcher app) when no real Xcode is present. Iterate candidates and only accept ones that actually contain Contents/Developer/usr/bin/xcodebuild. --- script/macos/bootstrap | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script/macos/bootstrap b/script/macos/bootstrap index d45fd59f9..ca0800692 100755 --- a/script/macos/bootstrap +++ b/script/macos/bootstrap @@ -7,7 +7,13 @@ set -e DEVELOPER_DIR="$(xcode-select -p 2>/dev/null || true)" if [ -z "$DEVELOPER_DIR" ] || [ ! -x "$DEVELOPER_DIR/usr/bin/xcodebuild" ] || [ "$DEVELOPER_DIR" = "/Library/Developer/CommandLineTools" ]; then - XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | head -n 1)" + XCODE_APP="" + for candidate in /Applications/Xcode*.app; do + if [ -x "$candidate/Contents/Developer/usr/bin/xcodebuild" ]; then + XCODE_APP="$candidate" + break + fi + done if [ -z "$XCODE_APP" ]; then echo "Please install Xcode before continuing." exit 1 From 1bc11b0be9e984d7f7a26a1c967cac7407f5c1cd Mon Sep 17 00:00:00 2001 From: Sagar Dagdu Date: Tue, 5 May 2026 10:56:38 +0530 Subject: [PATCH 3/4] fix(bootstrap): prefer /Applications/Xcode.app in fallback scan When the user has both /Applications/Xcode.app (stable) and a versioned/beta install (e.g. Xcode-15.4.0.app, Xcode-beta.app), shell glob expansion is lexical and the older/beta name sorts before Xcode.app, which would have switched users away from the stable install the original script preferred. Try Xcode.app explicitly first, then fall back to the glob scan only if it is missing. --- script/macos/bootstrap | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/script/macos/bootstrap b/script/macos/bootstrap index 1df5bfbf3..e233168d0 100755 --- a/script/macos/bootstrap +++ b/script/macos/bootstrap @@ -10,12 +10,18 @@ set -e DEVELOPER_DIR="$(xcode-select -p 2>/dev/null || true)" if [ -z "$DEVELOPER_DIR" ] || [ ! -x "$DEVELOPER_DIR/usr/bin/xcodebuild" ] || [ "$DEVELOPER_DIR" = "/Library/Developer/CommandLineTools" ]; then XCODE_APP="" - for candidate in /Applications/Xcode*.app; do - if [ -x "$candidate/Contents/Developer/usr/bin/xcodebuild" ]; then - XCODE_APP="$candidate" - break - fi - done + # Prefer the stable /Applications/Xcode.app when present so users with + # both stable and beta/versioned installs aren't switched away from it. + if [ -x "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" ]; then + XCODE_APP="/Applications/Xcode.app" + else + for candidate in /Applications/Xcode*.app; do + if [ -x "$candidate/Contents/Developer/usr/bin/xcodebuild" ]; then + XCODE_APP="$candidate" + break + fi + done + fi if [ -z "$XCODE_APP" ]; then echo "Please install Xcode before continuing." exit 1 From 0a0c3309612c3606daa8a0dcdf7558134ca906ed Mon Sep 17 00:00:00 2001 From: Sagar Dagdu Date: Tue, 5 May 2026 22:28:09 +0530 Subject: [PATCH 4/4] fix(bootstrap): echo selected Xcode before xcode-select switch Surfaces which Xcode the fallback scan picked, so users can see (and verify, since warp_sudo will prompt next) what is about to be made the active developer dir. --- script/macos/bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/script/macos/bootstrap b/script/macos/bootstrap index e233168d0..fea3bae4c 100755 --- a/script/macos/bootstrap +++ b/script/macos/bootstrap @@ -26,6 +26,7 @@ if [ -z "$DEVELOPER_DIR" ] || [ ! -x "$DEVELOPER_DIR/usr/bin/xcodebuild" ] || [ echo "Please install Xcode before continuing." exit 1 fi + echo "Selected Xcode at $XCODE_APP" warp_sudo xcode-select --switch "$XCODE_APP/Contents/Developer" fi # Mimic actually launching XCode, which performs some necessary set-up of the