Skip to content

Commit 527b7c2

Browse files
authored
fix(install): skip Homebrew until macOS packages need it
Keep macOS Homebrew setup lazy so users with supported Node and Git can install without admin/Homebrew, while still installing Homebrew before macOS Node or Git package installs. Updates installer docs and adds focused install.sh coverage for the lazy Git path. Also aligns the live-media provider expectation with current main so built-artifact checks stay green. Fixes #83232 Co-authored-by: Sebastien Tardif <[email protected]>
1 parent 351aac9 commit 527b7c2

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

docs/install/installer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ Recommended for most interactive installs on macOS/Linux/WSL.
6868

6969
<Steps>
7070
<Step title="Detect OS">
71-
Supports macOS and Linux (including WSL). If macOS is detected, installs Homebrew if missing.
71+
Supports macOS and Linux (including WSL).
7272
</Step>
7373
<Step title="Ensure Node.js 24 by default">
74-
Checks Node version and installs Node 24 if needed (Homebrew on macOS, NodeSource setup scripts on Linux apt/dnf/yum). OpenClaw still supports Node 22 LTS, currently `22.19+`, for compatibility.
74+
Checks Node version and installs Node 24 if needed (Homebrew on macOS, NodeSource setup scripts on Linux apt/dnf/yum). On macOS, Homebrew is installed only when the installer needs it for Node or Git. OpenClaw still supports Node 22 LTS, currently `22.19+`, for compatibility.
7575
On Alpine/musl Linux, the installer uses apk packages instead of NodeSource; the configured Alpine repositories must provide Node `22.19+` (Alpine 3.21 or newer at the time of writing).
7676
</Step>
7777
<Step title="Ensure Git">
78-
Installs Git if missing using the detected package manager, including apk on Alpine.
78+
Installs Git if missing using the detected package manager, including Homebrew on macOS and apk on Alpine.
7979
</Step>
8080
<Step title="Install OpenClaw">
8181
- `npm` method (default): global npm install

scripts/install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,7 @@ require_sudo() {
19141914

19151915
install_git() {
19161916
if [[ "$OS" == "macos" ]]; then
1917+
install_homebrew
19171918
run_quiet_step "Installing Git" brew install git
19181919
elif [[ "$OS" == "linux" ]]; then
19191920
require_sudo
@@ -3100,12 +3101,11 @@ main() {
31003101

31013102
ui_stage "Preparing environment"
31023103

3103-
# Step 1: Homebrew (macOS only)
3104-
install_homebrew
3105-
3106-
# Step 2: Node.js
3104+
# Step 1: Node.js. macOS package-manager branches install Homebrew lazily
3105+
# only when they are about to call brew.
31073106
load_nvm_for_node_detection
31083107
if ! check_node; then
3108+
install_homebrew
31093109
install_node
31103110
fi
31113111
activate_supported_node_on_path || true

src/scripts/test-live-media.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("test-live-media", () => {
4949
"openai",
5050
"vydra",
5151
]);
52-
expect(requirePlanEntry(plan, "music").providers).toEqual(["google", "minimax"]);
52+
expect(requirePlanEntry(plan, "music").providers).toEqual(["fal", "google", "minimax"]);
5353
expect(requirePlanEntry(plan, "video").providers).toEqual([
5454
"google",
5555
"minimax",

test/scripts/install-sh.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ describe("install.sh", () => {
826826

827827
it("loads nvm before checking Node.js so stale system Node does not win", () => {
828828
expect(script).toMatch(
829-
/# Step 2: Node\.js\s+load_nvm_for_node_detection\s+if ! check_node; then/,
829+
/# Step 1: Node\.js[\s\S]*?load_nvm_for_node_detection\s+if ! check_node; then/,
830830
);
831831

832832
const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-nvm-"));
@@ -890,6 +890,22 @@ describe("install.sh", () => {
890890
expect(output).toContain("version=v22.22.1");
891891
});
892892

893+
it("installs Homebrew lazily before macOS Git installs", () => {
894+
const result = runInstallShell(`
895+
set -euo pipefail
896+
source "${SCRIPT_PATH}"
897+
OS=macos
898+
install_homebrew() { echo "install_homebrew"; }
899+
run_quiet_step() { echo "run_quiet_step:$*"; return 0; }
900+
install_git
901+
`);
902+
903+
expect(result.status).toBe(0);
904+
expect(result.stdout).toMatch(
905+
/install_homebrew\s+run_quiet_step:Installing Git brew install git/,
906+
);
907+
});
908+
893909
it("promotes a supported Linux Node binary over stale PATH entries", () => {
894910
const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-node-promote-"));
895911
const staleBin = join(tmp, "usr-local-bin");

0 commit comments

Comments
 (0)