Skip to content

fix(npm): do not treat non-executable PATH entries as installed binaries - #78

Closed
DivyamTalwar wants to merge 1 commit into
hanzoai:mainfrom
DivyamTalwar:fix/npm-ignore-nonexecutable-path-companions
Closed

DivyamTalwar wants to merge 1 commit into
hanzoai:mainfrom
DivyamTalwar:fix/npm-ignore-nonexecutable-path-companions

Conversation

@DivyamTalwar

Copy link
Copy Markdown

Problem

@hanzo/cli may skip the native companion's lazy install if PATH contains a directory or a non-executable regular file named hanzod, hanzo-mcp, etc. Such entries cannot be launched, but the launcher currently counts them as installed binaries based only on existsSync() and the resolved filename.

Change

Only recognize native PATH candidates that resolve to regular files and, on POSIX systems, have execute permission. Preserve the existing protection against npm .js shims.

Verified

  • Red on unmodified main: both new integration tests failed when non-executable hanzod file and a hanzod/ directory suppressed the expected lazy install.
  • Green: node --test npm/install.test.js npm/launcher-presence.test.js — 7 passed, 3 Windows/Linux-only skips, 0 failures on macOS.
  • node --check for launcher and test, plus git diff --check, passed.

No new dependencies, releases, or public API changes. Does not overlap open installer PR #9 or the separate termination-signal fix #76 (different code hunk).

zeekay added a commit that referenced this pull request Nov 25, 2026
…cher reliability (#92)

Consolidates #81, #79, #82, #77, #80, #78, and #76 into a single audited npm installer and launcher update:
- Security (#81): refuse empty or malformed .sha256 responses (require 64-hex SHA-256, normalize uppercase), and fail closed on invalid checksums for optional companions too.
- Security (#79): use lstatSync in linkAlias and unlink dangling symlinks before try/fallback so copyFileSync can never write through a stale symlink.
- Integrity (#82): extract standard tools in an isolated staging dir, reject missing/empty/directory/symlink placeholders, unlink existing destination entries before cpSync (preventing macOS cpSync abort on dangling symlinks and Linux ETXTBSY), preserve sidecar files, and keep prior installs intact on failure.
- Cleanup (#77): remove temporary downloaded archives in finally on all error paths.
- Reliability (#80): reject missing or flag-shaped values for -m/--model/-p/--port/--overlay in ENGINE_ADAPTER instead of infinite-looping; export ENGINE_ADAPTER.
- Reliability (#78): require regular executable files (not directories or non-executable files) on PATH in realBinary() and hasLocal(); isolate PATH in launcher-presence tests.
- Reliability (#76): propagate native child termination signals (mapping SIGUSR1/SIGPIPE to 128+sig instead of invoking Node inspector or ignoring SIGPIPE), treat missing status as 1, preserve 0755 mode on npm/bin/hanzo.js, and run all npm/*.test.js in Makefile test target.

Co-authored-by: Hanzo Dev <[email protected]>
@zeekay

zeekay commented Nov 25, 2026

Copy link
Copy Markdown
Member

Audited, hardened, and consolidated with #76–#82 into #92, merged into main at commit 6ae231d71c3377a700242ad810ee8153d1e9fdca (with full Co-authored-by attribution to @DivyamTalwar). Verified with node --test npm/*.test.js (23 passed, 0 failed, 3 platform skips under read-only HOME). Thank you!

@zeekay zeekay closed this Nov 25, 2026
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.

2 participants