Skip to content

Commit 5b8fa2a

Browse files
tannevaledclaude
andcommitted
address remaining Copilot remark: verify versioned pkgx candidate
Copilot's review on 18e0471 flagged that the versioned-layout fallback (`~/.pkgx/pkgx.sh/v<x.y.z>/bin/pkgx`) picked candidates based only on the directory-name semver and existence of the binary, while the other fallback paths (~/.local/bin/pkgx, /usr/local/bin/pkgx) verify candidates with pkgx_meets_minimum(). A stale, non-executable, or version-mismatched v*/bin/pkgx could therefore be returned and break the inner sudo invocation. Keep the directory-name semver as a cheap pre-filter — it lets us skip old-version dirs without spawning --version per entry — but verify the actual binary with pkgx_meets_minimum() before accepting it as `best`. The other two Copilot remarks on this commit either don't apply (Linuxbrew exemption already landed in e1104ea, sits before the /home|Users/ rejection) or are stale (the ci.yml comment refers to `set -ux` / `rc=$?` from ea4dab6 which I already removed in 18e0471; the current step uses `set -eux`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 18e0471 commit 5b8fa2a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎pkgm.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,11 @@ function pkgx_reachable_as(current: string, user: string): string | undefined {
884884
if (v.lt(PKGX_MIN_VERSION)) continue;
885885
const path = join(root, entry.name, "bin/pkgx");
886886
if (!existsSync(path)) continue;
887+
// Directory-name version is a cheap pre-filter; verify the
888+
// actual binary too, matching the other fallback paths so a
889+
// stale or non-executable `v*/bin/pkgx` can't be returned
890+
// (per #86 review).
891+
if (!pkgx_meets_minimum(path)) continue;
887892
if (!best || v.gt(best.v)) best = { v, path };
888893
} catch {
889894
// skip malformed version dir

0 commit comments

Comments
 (0)