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 <noreply@anthropic.com>
This commit is contained in:
@@ -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..."
|
||||
|
||||
|
||||
@@ -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..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user