pi 패키지 설치시 pi 못찾아 발생하는 묹제 해결
This commit is contained in:
1 parent
cf4863c575
commit
c3a59167a3
3 files changed
+200
-80
No files matched your search
+63
-11
@@ -97,30 +97,73 @@ if ($piCmd) {
|
||||
Success "Pi installed via npm"
|
||||
}
|
||||
|
||||
# Verify pi is available
|
||||
# ────────────────────────────────────────────
|
||||
# Resolve pi binary path (may not be in PATH yet after fresh install)
|
||||
# ────────────────────────────────────────────
|
||||
$piBin = $null
|
||||
|
||||
# 1) Try current PATH
|
||||
$piCmd = Get-Command pi -ErrorAction SilentlyContinue
|
||||
if ($piCmd) {
|
||||
Success "Pi is available: $($piCmd.Source)"
|
||||
} else {
|
||||
# Refresh PATH for current session
|
||||
$piBin = $piCmd.Source
|
||||
}
|
||||
|
||||
# 2) Refresh PATH from registry and try again
|
||||
if (-not $piBin) {
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
||||
$piCmd = Get-Command pi -ErrorAction SilentlyContinue
|
||||
if ($piCmd) {
|
||||
Success "Pi is available: $($piCmd.Source)"
|
||||
} else {
|
||||
ErrExit "'pi' command not found. Check your PATH."
|
||||
$piBin = $piCmd.Source
|
||||
}
|
||||
}
|
||||
|
||||
# 3) Try common npm global locations
|
||||
if (-not $piBin) {
|
||||
$npmPrefix = & npm config get prefix 2>$null
|
||||
if ($LASTEXITPR -eq 0 -and $npmPrefix) {
|
||||
$candidate = Join-Path $npmPrefix 'pi.cmd'
|
||||
if (Test-Path $candidate) { $piBin = $candidate }
|
||||
if (-not $piBin) {
|
||||
$candidate = Join-Path $npmPrefix 'pi'
|
||||
if (Test-Path $candidate) { $piBin = $candidate }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 4) Try well-known locations
|
||||
if (-not $piBin) {
|
||||
$candidates = @(
|
||||
(Join-Path $env:APPDATA 'npm\pi.cmd'),
|
||||
(Join-Path $env:APPDATA 'npm\pi'),
|
||||
'C:\Program Files\nodejs\pi.cmd',
|
||||
'C:\Program Files\nodejs\pi'
|
||||
)
|
||||
foreach ($c in $candidates) {
|
||||
if (Test-Path $c) { $piBin = $c; break }
|
||||
}
|
||||
}
|
||||
|
||||
if ($piBin) {
|
||||
# Add pi's directory to PATH for this session
|
||||
$piDir = Split-Path $piBin
|
||||
if ($env:Path -notlike "*$piDir*") {
|
||||
$env:Path = "$piDir;$env:Path"
|
||||
Info "Added $piDir to PATH for this session"
|
||||
}
|
||||
Success "Pi is available: $piBin"
|
||||
} else {
|
||||
ErrExit "'pi' command not found after installation. Check your PATH or reinstall Node.js."
|
||||
}
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Step 2: Install packages
|
||||
# Step 2: Install packages using the resolved pi binary
|
||||
# ────────────────────────────────────────────
|
||||
if ($SkipPackages) {
|
||||
Info "Skipping package installation (-SkipPackages flag)."
|
||||
} else {
|
||||
Info ""
|
||||
Info "Installing Pi packages..."
|
||||
Info "────────────────────────────────────────"
|
||||
Info "---------------------------------------------------"
|
||||
|
||||
$total = $Packages.Count
|
||||
$count = 0
|
||||
@@ -133,7 +176,7 @@ if ($SkipPackages) {
|
||||
|
||||
Info "[$count/$total] $name - $desc"
|
||||
try {
|
||||
& pi install "npm:$name" 2>&1 | Out-Null
|
||||
& $piBin install "npm:$name" 2>&1 | Out-Null
|
||||
if ($LASTEXITPR -eq 0) {
|
||||
Success " -> $name installed"
|
||||
} else {
|
||||
@@ -147,7 +190,7 @@ if ($SkipPackages) {
|
||||
}
|
||||
|
||||
Info ""
|
||||
Info "────────────────────────────────────────"
|
||||
Info "---------------------------------------------------"
|
||||
if ($failed.Count -eq 0) {
|
||||
Success "All packages installed! ($total/$total)"
|
||||
} else {
|
||||
@@ -170,6 +213,15 @@ Info "=================================================="
|
||||
Success "Pi Coding Agent installation complete!"
|
||||
Info "=================================================="
|
||||
Info ""
|
||||
Info "Pi binary: $piBin"
|
||||
Info ""
|
||||
$piDir = Split-Path $piBin
|
||||
$userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||
if ($userPath -notlike "*$piDir*") {
|
||||
Info "NOTE: Add $piDir to your PATH permanently by running:"
|
||||
Info " [System.Environment]::SetEnvironmentVariable('Path', '$piDir;' + [System.Environment]::GetEnvironmentVariable('Path', 'User'), 'User')"
|
||||
}
|
||||
Info ""
|
||||
Info "Getting started:"
|
||||
Info " 1. Navigate to your project: cd C:\path\to\project"
|
||||
Info " 2. Start Pi: pi"
|
||||
|
||||
Reference in new issue
Block a user