避免踩雷的正確安裝順序。直接跑
irm https://omp.sh/install.ps1 | iex會因為缺少前置依賴而失敗。
- Windows 10/11(x64)
- PowerShell 5.1+ 或 PowerShell 7+(建議 7)
- 系統管理員權限(安裝 VC++ Runtime 時需要)
| 問題 | 症狀 | 原因 |
|---|---|---|
| Native addon 載入失敗 | Failed to load pi_natives native addon for win32-x64 |
缺少 Visual C++ Redistributable |
| MCP/工具無法執行 | 各種 node 相關錯誤 | 缺少 Node.js |
| SSH 遠端安裝失敗 | winget 卡住不動 | 缺少 --accept-source-agreements flag |
omp 的 Rust native addon(pi_natives.win32-x64-baseline.node)依賴 vcruntime140.dll。
# 檢查是否已安裝
Test-Path "C:\Windows\System32\vcruntime140.dll"
# 若為 False,安裝:
winget install Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreementsomp 的部分工具(MCP server、npm 套件整合)需要 Node.js 環境。
# 安裝 Node.js LTS
winget install OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements
# 驗證(新開 PowerShell 視窗後)
node --version
npm --versionomp 需要 bash shell 來執行 shell snapshots 和互動式終端。沒裝的話會用內建 shell,功能受限。
# 安裝 Git(含 bash)
winget install Git.Git --accept-source-agreements --accept-package-agreements
# 驗證
git --version前置依賴都到位後,安裝 omp 本體:
# 官方安裝腳本
irm https://omp.sh/install.ps1 | iex安裝完成後驗證:
omp --version# 方法 A:設定環境變數(永久)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-ant-xxx", "User")
# 或
[System.Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-xxx", "User")
# 方法 B:互動式登入(開啟 omp 後)
omp
# 進入後輸入 /login# 所有前置依賴
Test-Path "C:\Windows\System32\vcruntime140.dll" # True
node --version # v24.x
git --version # git version 2.x
omp --version # omp/17.x
# 功能測試
omp --print "say hello"將以下存為 install-omp.ps1,以系統管理員身分執行:
#Requires -RunAsAdministrator
Write-Host "=== [1/4] Installing Visual C++ Redistributable ===" -ForegroundColor Cyan
winget install Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreements
Write-Host "=== [2/4] Installing Node.js LTS ===" -ForegroundColor Cyan
winget install OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements
Write-Host "=== [3/4] Installing Git for Windows ===" -ForegroundColor Cyan
winget install Git.Git --accept-source-agreements --accept-package-agreements
Write-Host "=== [4/4] Installing Oh My Pi ===" -ForegroundColor Cyan
irm https://omp.sh/install.ps1 | iex
Write-Host "`n=== Done! ===" -ForegroundColor Green
Write-Host "Open a NEW PowerShell window, then run: omp --version" -ForegroundColor Yellow
Write-Host "Set API key: [System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'your-key', 'User')" -ForegroundColor Yellow若要透過 SSH 在遠端 Windows 機器上安裝,注意:
- 確保 OpenSSH Server 已啟用且 DefaultShell 設為 PowerShell
- 所有 winget 指令必須加
--accept-source-agreements --accept-package-agreements(非互動式環境不會跳確認) - 安裝後 PATH 更新可能需要重新建立 SSH 連線才會生效
# 設定 PowerShell 7 為 SSH 預設 shell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\PowerShell\7\pwsh.exe" -PropertyType String -Force
Restart-Service sshd# 1. 確認 VC++ Runtime 存在
Test-Path "C:\Windows\System32\vcruntime140.dll"
# 2. 若存在但仍失敗,刪除 natives 快取重裝
Remove-Item "$env:USERPROFILE\.omp\natives" -Recurse -Force
omp --version # 會自動重新提取 native addon# 確認安裝路徑在 PATH 中
$env:PATH -split ";" | Where-Object { $_ -match "omp" }
# 手動加入(當次生效)
$env:PATH += ";$env:LOCALAPPDATA\omp"
# 永久加入
[System.Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";$env:LOCALAPPDATA\omp", "User")新開一個 PowerShell 視窗(PATH 在安裝後更新,舊視窗不會自動刷新)。