fix: delete management/ncp.ps1 - it shadowed the ncp.cmd PATH shim

PowerShell resolves ExternalScript (.ps1) ahead of Application (.cmd), and both
lived in the directory the installer puts on PATH -- so in PowerShell `ncp` ran
the .ps1 and was execution-policy-bound again, the exact thing the .cmd exists
to avoid. Its other justification (giving ncp to pwsh on Linux) stopped being
true once /usr/local/bin/ncp existed: pwsh runs a PATH symlink to a shell script
as an Application. A test now prevents the file coming back.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jon
2026-07-22 14:59:56 -05:00
co-authored by Claude Opus 4.8
parent b5564c4720
commit 786552b790
6 changed files with 22 additions and 61 deletions
+6 -1
View File
@@ -3,7 +3,12 @@ REM ncp - PATH entry point on Windows. A .cmd, not a .ps1, on purpose: PowerShel
REM execution policy governs .ps1 only, so this keeps working under the default
REM Restricted policy and from cmd, Win+R, Task Scheduler and .lnk targets - none
REM of which load a PowerShell profile. install-windows.ps1 puts this directory on
REM the machine PATH. ncp.ps1 stays for pwsh-on-Linux, where there is no PATH shim.
REM the machine PATH.
REM
REM This file must NOT be accompanied by an ncp.ps1 in the same directory:
REM PowerShell resolves ExternalScript (.ps1) ahead of Application (.cmd), so a
REM sibling ncp.ps1 wins in PowerShell and drags the execution policy back in -
REM exactly what this file exists to avoid.
REM
REM ASCII only, same rule as the .ps1 files - a test in tests/test_smoke.py enforces it.
setlocal
-43
View File
@@ -1,43 +0,0 @@
# ncp - PowerShell entry point. The CLI itself is management/ncp.py, the same
# file the Linux shell wrapper runs; this only picks an interpreter and forwards
# the arguments.
#
# On Windows, ncp comes from management/ncp.cmd on the machine PATH instead (a
# .cmd is not subject to the execution policy and works outside PowerShell too) -
# install-windows.ps1 sets that up. This file is what gives ncp to pwsh on Linux,
# where restore-linux.sh registers it in $PROFILE.CurrentUserAllHosts as:
#
# function ncp { & "<repo>/management/ncp.ps1" @args }
#
# ASCII only, no exceptions: PowerShell 5.1 decodes BOM-less files as ANSI, so a
# single Unicode dash eats a quote and the script dies at parse time. A test in
# tests/test_smoke.py fails if any .ps1 in this repo gains a non-ASCII byte.
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
# Forward slashes and per-platform venv layout: backslash is a literal character
# on Linux, not a separator, so "Promethean\Scripts\python.exe" would resolve to
# a single nonsense filename under pwsh on Linux. Windows accepts "/" happily.
# $env:OS is the 5.1-safe check; the automatic $IsWindows only exists on PS 6+.
$OnWindows = ($env:OS -eq "Windows_NT")
if ($OnWindows) {
$Py = Join-Path $Root "Promethean/Scripts/python.exe"
} else {
$Py = Join-Path $Root "Promethean/bin/python3"
}
# Fall back to a system Python so backup/restore still work before the venv is
# built - those delegate to the stdlib-only bin/sync.py.
if (-not (Test-Path $Py)) {
foreach ($candidate in @("python3", "python")) {
$found = Get-Command $candidate -ErrorAction SilentlyContinue
if ($found) { $Py = $found.Source; break }
}
}
if (-not (Test-Path $Py)) {
Write-Error "No Python found. Run install.sh (Linux) or install-windows.ps1 first."
exit 1
}
& $Py (Join-Path $Root "management/ncp.py") @args
exit $LASTEXITCODE
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ncp - Linux entry point. The CLI itself is management/ncp.py, which runs
# unchanged on Windows too (see management/ncp.ps1); this stays a shell script
# unchanged on Windows too (see management/ncp.cmd); this stays a shell script
# because ~/.bashrc, launch_nexus.sh, bin/restore-linux.sh, controlpanel.py,
# bin/panel/nexus-popup.py and management/nexus-app.sh all invoke this path.
#