Skip to content

setup: correct the mechanism in #6, and widen it past npm's own cache - #7

Open
noammigdali-hio wants to merge 1 commit into
petergyang:mainfrom
noammigdali-hio:fix/widen-transient-bin-detection
Open

setup: correct the mechanism in #6, and widen it past npm's own cache#7
noammigdali-hio wants to merge 1 commit into
petergyang:mainfrom
noammigdali-hio:fix/widen-transient-bin-detection

Conversation

@noammigdali-hio

Copy link
Copy Markdown
Contributor

Written by Claude Opus 5, which also wrote #6 and the mistake in it. Caught by adversarial review that finished shortly after #6 was merged.

#6 has three problems. This fixes all three.

The comment is factually wrong. It says the cached binary "is gone the moment npx exits". npm's npx cache persists on disk; the machine this was tested on has fifteen populated hash directories under ~/.npm/_npx right now. What goes away is the PATH entry, not the binary. It is the sentence the change rests on, so it is worth correcting even though the code behaves as intended.

The fix is narrower than the bug. Keying on _npx catches npm's cache and nothing else. pnpm dlx, yarn dlx, bunx, and setup run inside a project that already depends on human-review all produce the same failure, and all resolve through a node_modules segment instead. isTransientBin now checks for either.

The test cannot detect the bug. It only exercises the path helper, so reverting the fix in invocation() leaves it green. There is now a test that drives invocation() with a transient bin on PATH; it fails against main as it stands and passes with this change. 69 pass.

Durable installs still keep the short form: npm i -g, npm link, volta, nvm, asdf, pnpm and yarn globals all resolve through a bin directory with neither segment. A durable path that happens to contain one degrades to the npx form, which always works, so the failure direction is cosmetic.

Simpler option if you would rather drop the optimisation. Have invocation() always return npx -y human-review and delete the probe entirely. npx already prefers a suitable local or global install, so the short form saves nothing at runtime, and it removes any dependency on npm's cache layout. That deletes a feature you wrote deliberately, so I have not done it. Say the word and I will.

🤖 Generated with Claude Code

The first commit on this branch claimed the cached binary "is gone the moment
npx exits". That is false. npm's npx cache persists on disk; what goes away is
the PATH entry. A mechanism was asserted rather than checked, in the single
sentence the change rested on.

The fix was also too narrow. Keying on `_npx` misses every other channel that
produces the same failure: `pnpm dlx`, `yarn dlx`, `bunx`, and setup run inside
a project that already depends on human-review. All of them resolve through a
`node_modules` segment.

The test only exercised the path helper, so reverting the fix left it green. It
now drives `invocation()` with a transient bin on PATH, and fails against the
previous commit.

Written by Claude Opus 5; the wrong claim above was caught by adversarial
review from GPT-5.6 and Grok 4.5.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant