From 1a84adb97be5fe35c3d990275045a317309db155 Mon Sep 17 00:00:00 2001 From: Rick Mu Date: Fri, 13 Feb 2026 19:01:15 +1100 Subject: [PATCH] Add Git install step before OpenClaw (fixes npm ENOENT spawn git) OpenClaw npm dependencies require git. Add check/install via winget or choco, with fallback to git-scm.com manual download. Co-Authored-By: Claude Opus 4.6 --- install-windows-en.ps1 | 40 +++++++++++++++++++++++++++++++++++++++- install-windows.ps1 | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/install-windows-en.ps1 b/install-windows-en.ps1 index 68bb54c..0ea38f8 100644 --- a/install-windows-en.ps1 +++ b/install-windows-en.ps1 @@ -85,7 +85,45 @@ if ($needsNode) { } # ───────────────────────────────────────────── -# Step 2: Install OpenClaw +# Step 2: Check / Install Git +# ───────────────────────────────────────────── +Write-Info "Checking Git..." + +if (Get-Command git -ErrorAction SilentlyContinue) { + Write-Ok "Found Git." +} else { + Write-Info "Installing Git (required by OpenClaw dependencies)..." + + $gitInstalled = $false + + if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) { + Write-Info "Installing Git via winget..." + winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null + if ($LASTEXITCODE -eq 0) { + $gitInstalled = $true + Write-Ok "Git installed via winget" + } + } + + if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) { + Write-Info "Installing Git via Chocolatey..." + choco install git -y 2>$null + if ($LASTEXITCODE -eq 0) { + $gitInstalled = $true + Write-Ok "Git installed via Chocolatey" + } + } + + if (-not $gitInstalled) { + Write-Err "Could not install Git automatically. Please install manually and re-run this script:`n`n Download: https://git-scm.com/download/win`n`n After installing, reopen PowerShell and run this script again." + } + + # Refresh PATH + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") +} + +# ───────────────────────────────────────────── +# Step 3: Install OpenClaw # ───────────────────────────────────────────── Write-Info "Checking OpenClaw..." diff --git a/install-windows.ps1 b/install-windows.ps1 index 086c39f..5b637c4 100644 --- a/install-windows.ps1 +++ b/install-windows.ps1 @@ -85,7 +85,45 @@ if ($needsNode) { } # ───────────────────────────────────────────── -# 步骤 2: 安装 OpenClaw +# 步骤 2: 检查 / 安装 Git +# ───────────────────────────────────────────── +Write-Info "正在检查 Git..." + +if (Get-Command git -ErrorAction SilentlyContinue) { + Write-Ok "已找到 Git。" +} else { + Write-Info "正在安装 Git(OpenClaw 依赖需要)..." + + $gitInstalled = $false + + if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) { + Write-Info "使用 winget 安装 Git..." + winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null + if ($LASTEXITCODE -eq 0) { + $gitInstalled = $true + Write-Ok "Git 已通过 winget 安装" + } + } + + if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) { + Write-Info "使用 Chocolatey 安装 Git..." + choco install git -y 2>$null + if ($LASTEXITCODE -eq 0) { + $gitInstalled = $true + Write-Ok "Git 已通过 Chocolatey 安装" + } + } + + if (-not $gitInstalled) { + Write-Err "无法自动安装 Git。请手动下载安装:`n`n 下载地址:https://git-scm.com/download/win`n`n 安装完成后重新打开 PowerShell 运行此脚本。" + } + + # 刷新 PATH + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") +} + +# ───────────────────────────────────────────── +# 步骤 3: 安装 OpenClaw # ───────────────────────────────────────────── Write-Info "正在检查 OpenClaw..."