diff --git a/install/bash/install.sh b/install/bash/install.sh index 72b55a93..e8cb2be2 100755 --- a/install/bash/install.sh +++ b/install/bash/install.sh @@ -312,13 +312,24 @@ fi PLAIN_FORGE_INSTALLED=false if [[ ! "${INSTALL_PLAIN_FORGE:-}" =~ ^[Nn]$ ]]; then - if command -v npx &> /dev/null; then - npx plain-forge install < /dev/tty - PLAIN_FORGE_INSTALLED=true + # A stale nvm/volta/asdf shim can make npx resolvable without a working + # Node.js behind it, so verify node actually runs before invoking npx. + if command -v npx &> /dev/null && node --version &> /dev/null; then + # The install must not abort the rest of the setup if plain-forge + # fails (set -e is active), so run it inside the condition. + if npx plain-forge install < /dev/tty; then + PLAIN_FORGE_INSTALLED=true + else + echo -e "${GRAY}plain-forge installation failed. You can retry later with:${NC}" + echo -e " npx plain-forge install" + fi echo "" else - echo -e "${GRAY}npx not found. Install Node.js, then run:${NC}" - echo -e " npx plain-forge install" + echo -e " ${GRAY}plain-forge brings codeplain's agentic skills to your coding agent,${NC}" + echo -e " ${GRAY}but installing it requires Node.js, which was not found on this machine.${NC}" + echo "" + echo -e " ${GRAY}If you want it, install Node.js and then run:${NC}" + echo -e " ${WHITE}${BOLD}npx plain-forge install${NC}" echo "" fi fi diff --git a/install/powershell/install.ps1 b/install/powershell/install.ps1 index 0ac18e80..8c96e0ca 100644 --- a/install/powershell/install.ps1 +++ b/install/powershell/install.ps1 @@ -347,13 +347,39 @@ if ($nonInteractive) { $plainForgeInstalled = $false if ($installPlainForge -notmatch '^[Nn]$') { - if (Get-Command npx -ErrorAction SilentlyContinue) { - npx plain-forge install - $plainForgeInstalled = $true + # A stale version-manager shim can make npx resolvable without a working + # Node.js behind it, so verify node actually runs before invoking npx. + $nodeWorks = $false + if ((Get-Command node -ErrorAction SilentlyContinue) -and (Get-Command npx -ErrorAction SilentlyContinue)) { + try { + & node --version *> $null + $nodeWorks = ($LASTEXITCODE -eq 0) + } catch { + $nodeWorks = $false + } + } + if ($nodeWorks) { + # A plain-forge failure must not abort the rest of the setup + # ($ErrorActionPreference is 'Stop'). + try { + npx plain-forge install + if ($LASTEXITCODE -eq 0) { + $plainForgeInstalled = $true + } + } catch { + # fall through to the retry hint below + } + if (-not $plainForgeInstalled) { + Write-Host "${GRAY}plain-forge installation failed. You can retry later with:${NC}" + Write-Host " npx plain-forge install" + } Write-Host "" } else { - Write-Host "${GRAY}npx not found. Install Node.js, then run:${NC}" - Write-Host " npx plain-forge install" + Write-Host " ${GRAY}plain-forge brings codeplain's agentic skills to your coding agent,${NC}" + Write-Host " ${GRAY}but installing it requires Node.js, which was not found on this machine.${NC}" + Write-Host "" + Write-Host " ${GRAY}If you want it, install Node.js and then run:${NC}" + Write-Host " ${WHITE}${BOLD}npx plain-forge install${NC}" Write-Host "" } }