From 5d0000634c49452ff5f38c23dff81aa97a0d7293 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Tue, 17 Mar 2026 18:20:05 -0700 Subject: [PATCH] cmd/launch: check for both npm and git before installing OpenClaw (#14888) The OpenClaw installer requires git in addition to npm. Update the dependency check to detect both and provide specific install guidance for whichever dependencies are missing. --- cmd/launch/launch_test.go | 2 +- cmd/launch/openclaw.go | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/launch/launch_test.go b/cmd/launch/launch_test.go index f9a9f79a9..359deff37 100644 --- a/cmd/launch/launch_test.go +++ b/cmd/launch/launch_test.go @@ -951,7 +951,7 @@ func TestLaunchIntegration_OpenclawInstallsBeforeConfigSideEffects(t *testing.T) if err == nil { t.Fatal("expected launch to fail before configuration when OpenClaw is missing") } - if !strings.Contains(err.Error(), "npm was not found") { + if !strings.Contains(err.Error(), "required dependencies are missing") { t.Fatalf("expected install prerequisite error, got %v", err) } if selectorCalled { diff --git a/cmd/launch/openclaw.go b/cmd/launch/openclaw.go index 9285db79b..43e49bf62 100644 --- a/cmd/launch/openclaw.go +++ b/cmd/launch/openclaw.go @@ -429,13 +429,17 @@ func ensureOpenclawInstalled() (string, error) { return "clawdbot", nil } - if _, err := exec.LookPath("npm"); err != nil { - return "", fmt.Errorf("openclaw is not installed and npm was not found\n\n" + - "Install Node.js first:\n" + - " https://nodejs.org/\n\n" + - "Then rerun:\n" + - " ollama launch\n" + - "and select OpenClaw") + _, npmErr := exec.LookPath("npm") + _, gitErr := exec.LookPath("git") + if npmErr != nil || gitErr != nil { + var missing []string + if npmErr != nil { + missing = append(missing, "npm (Node.js): https://nodejs.org/") + } + if gitErr != nil { + missing = append(missing, "git: https://git-scm.com/") + } + return "", fmt.Errorf("openclaw is not installed and required dependencies are missing\n\nInstall the following first:\n %s", strings.Join(missing, "\n ")) } ok, err := ConfirmPrompt("OpenClaw is not installed. Install with npm?")