fix(macos): complete ChatGPT subscription setup (#120782)

Fresh Dev installs now preflight disk space and stream honest stages, while Codex activation probes the refreshed request-scoped registry.

Closes #120779
Closes #120780
This commit is contained in:
Peter Steinberger
2026-08-08 17:16:00 -07:00
committed by GitHub
parent 1758008a91
commit 915c25d713
11 changed files with 777 additions and 182 deletions
+73
View File
@@ -85,6 +85,7 @@ JSON=0
RUN_ONBOARD=0
SET_NPM_PREFIX=0
PNPM_CMD=()
FRESH_GIT_MIN_FREE_KIB=$((6 * 1024 * 1024))
print_usage() {
cat <<EOF
@@ -197,6 +198,50 @@ require_bin() {
fi
}
available_disk_kib() {
local target="$1"
df -Pk "$target" 2>/dev/null | awk 'NR == 2 { print $4; exit }' || true
}
preflight_fresh_git_disk_space() {
local repo_dir="$1"
local ancestor
local available_kib
local available_gib
if [[ "$repo_dir" != /* ]]; then
repo_dir="$(pwd)/$repo_dir"
fi
if [[ -d "$repo_dir/.git" ]]; then
return 0
fi
emit_json "{\"event\":\"step\",\"name\":\"disk-space\",\"status\":\"start\"}"
ancestor="$repo_dir"
while [[ ! -e "$ancestor" ]]; do
local parent
parent="$(dirname "$ancestor")"
if [[ "$parent" == "$ancestor" ]]; then
break
fi
ancestor="$parent"
done
if [[ ! -d "$ancestor" ]]; then
ancestor="$(dirname "$ancestor")"
fi
available_kib="$(available_disk_kib "$ancestor")"
if [[ ! "$available_kib" =~ ^[0-9]+$ ]]; then
emit_json "{\"event\":\"step\",\"name\":\"disk-space\",\"status\":\"warn\",\"reason\":\"unreadable\"}"
return 0
fi
if ((available_kib < FRESH_GIT_MIN_FREE_KIB)); then
available_gib="$(awk -v kib="$available_kib" 'BEGIN { printf "%.1f", kib / 1048576 }')"
fail "Fresh Git installs require at least 6 GiB of free disk space; only ${available_gib} GiB is available. Free disk space and retry."
fi
emit_json "{\"event\":\"step\",\"name\":\"disk-space\",\"status\":\"ok\"}"
}
has_sudo() {
command -v sudo >/dev/null 2>&1
}
@@ -1306,6 +1351,7 @@ ensure_pnpm_git_prepare_allowlist() {
install_openclaw_from_git() {
local repo_dir="$1"
local repo_url="https://github.com/openclaw/openclaw.git"
local fresh_checkout=0
if [[ -z "$repo_dir" ]]; then
fail "Git install dir cannot be empty"
@@ -1323,9 +1369,11 @@ install_openclaw_from_git() {
log "Installing Openclaw from GitHub (${repo_url})..."
fi
emit_json '{"event":"step","name":"git-tools","status":"start"}'
ensure_git
ensure_pnpm
ensure_pnpm_binary_for_scripts
emit_json '{"event":"step","name":"git-tools","status":"ok"}'
if [[ -d "$repo_dir/.git" ]] &&
! git --git-dir="$repo_dir/.git" --work-tree="$repo_dir" rev-parse --verify --quiet 'HEAD^{commit}' >/dev/null 2>&1; then
@@ -1336,21 +1384,34 @@ install_openclaw_from_git() {
:
elif [[ -d "$repo_dir" ]]; then
if [[ -z "$(ls -A "$repo_dir" 2>/dev/null || true)" ]]; then
emit_json '{"event":"step","name":"git-clone","status":"start"}'
git clone "$repo_url" "$repo_dir"
emit_json '{"event":"step","name":"git-clone","status":"ok"}'
fresh_checkout=1
else
fail "Git install dir exists but is not a git repo: ${repo_dir}"
fi
else
emit_json '{"event":"step","name":"git-clone","status":"start"}'
git clone "$repo_url" "$repo_dir"
emit_json '{"event":"step","name":"git-clone","status":"ok"}'
fresh_checkout=1
fi
local git_ref
git_ref="$(resolve_git_openclaw_ref)"
if [[ -z "$(git -C "$repo_dir" status --porcelain 2>/dev/null || true)" ]]; then
log "Using git ref: ${git_ref}"
if [[ "$fresh_checkout" -eq 0 ]]; then
emit_json '{"event":"step","name":"git-update","status":"start"}'
fi
checkout_git_openclaw_ref "$repo_dir" "$git_ref"
if [[ "$fresh_checkout" -eq 0 ]]; then
emit_json '{"event":"step","name":"git-update","status":"ok"}'
fi
else
log "Repo is dirty; skipping git checkout/update"
emit_json '{"event":"step","name":"git-update","status":"warn","reason":"dirty"}'
fi
if [[ -n "${REQUIRED_COMPATIBLE_VERSION:-}" ]]; then
@@ -1368,12 +1429,20 @@ install_openclaw_from_git() {
local install_lockfile_flag
install_lockfile_flag="$(git_install_lockfile_flag "$repo_dir" "$git_ref")"
emit_json '{"event":"step","name":"dependencies","status":"start"}'
CI="${CI:-true}" run_pnpm -C "$repo_dir" install "$install_lockfile_flag"
emit_json '{"event":"step","name":"dependencies","status":"ok"}'
emit_json '{"event":"step","name":"control-ui","status":"start"}'
if ! run_pnpm -C "$repo_dir" ui:build; then
log "UI build failed; continuing (CLI may still work)"
emit_json '{"event":"step","name":"control-ui","status":"warn"}'
else
emit_json '{"event":"step","name":"control-ui","status":"ok"}'
fi
emit_json '{"event":"step","name":"cli-build","status":"start"}'
run_pnpm -C "$repo_dir" build
emit_json '{"event":"step","name":"cli-build","status":"ok"}'
mkdir -p "${PREFIX}/bin"
cat > "${PREFIX}/bin/openclaw" <<EOF
@@ -1451,6 +1520,10 @@ main() {
RUN_ONBOARD=0
fi
if [[ "$INSTALL_METHOD" == "git" ]]; then
preflight_fresh_git_disk_space "$GIT_DIR"
fi
select_node_version_for_platform "$(os_detect)" "$(arch_detect)"
PATH="$(node_dir)/bin:${PREFIX}/bin:${PATH}"
export PATH