fix: add android platform support for Termux npm install#455
Conversation
`npm install -g @gitlawb/zero` failed on Android/Termux with EBADPLATFORM because `package.json` `os` array lacked `"android"`. Termux provides a Linux userspace — the existing `linux-arm64` binary works natively. - Add `"android"` to the `os` array in package.json. - Map `android` platform to `linux` in postinstall.mjs resolvePlatform(). Fixes #449
de096f8 to
fbfc2a0
Compare
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
WalkthroughAdds "android" to the supported ChangesAndroid platform support
Estimated code review effort: 1 (Trivial) | ~3 minutes Related issues: Suggested labels: enhancement, dependencies Suggested reviewers: Gitlawb 🐇 A hop from Linux to Termux's shore, Android joins the OS-array lore. No new binary to bake or brew— Just a mapping, tried and true. `npm install` now finds its way home once more.🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/postinstall.mjs (1)
65-77: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMapping looks correct; add regression coverage for the new case.
android→linuxfallthrough is correct and matches the PR's stated intent. The existing Go test table forresolvePlatform/asset resolution only coverslinux,darwin,win32— worth adding anandroid/arm64case there so a future refactor of this switch doesn't silently regress Termux support.Separately (non-blocking, since the author already verified
zero --helpon-device): Termux runs on Bionic libc rather than glibc, and dynamically-linked Linux binaries can require workarounds there. SinceresolvePlatformonly affects binary selection, not the binary's own linking, this is worth a mental note for futurelinux-arm64build changes (e.g., switching to CGO_ENABLED=1) that could reintroduce Termux breakage without the reporter's platform showing symptoms.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/postinstall.mjs` around lines 65 - 77, Add regression coverage for the new android platform mapping in resolvePlatform and the related asset-resolution Go test table. Update the existing tests around resolvePlatform/asset selection to include an android/arm64 case that verifies android falls through to linux, using the resolvePlatform symbol and the current platform-asset lookup helpers so future refactors don’t drop Termux support.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@scripts/postinstall.mjs`:
- Around line 65-77: Add regression coverage for the new android platform
mapping in resolvePlatform and the related asset-resolution Go test table.
Update the existing tests around resolvePlatform/asset selection to include an
android/arm64 case that verifies android falls through to linux, using the
resolvePlatform symbol and the current platform-asset lookup helpers so future
refactors don’t drop Termux support.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 78db3306-6cf5-41ce-a19b-9734d55f0630
📒 Files selected for processing (2)
package.jsonscripts/postinstall.mjs
Vasanthdev2004
left a comment
There was a problem hiding this comment.
looks good for me
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Approve — high value-to-cost platform fix
Worth it: yes, easily. Termux is the primary way people run CLI tools on Android, and it exposes a real Linux/aarch64 userspace where Zero's existing linux-arm64 binary runs natively. Before this, npm install -g @gitlawb/zero hard-failed on Termux with EBADPLATFORM solely because package.json's os array omitted "android" (#449). The fix reuses the already-published, already-checksummed linux-arm64 asset — no new build target, no new artifact, effectively zero permanent maintenance cost. Two lines in package.json, two in postinstall.mjs. Thanks @anandh8x.
Verified on Windows (worktree):
ZERO_INSTALL_DRY_RUN=1 ZERO_INSTALL_PLATFORM=android ZERO_INSTALL_ARCH=arm64 node scripts/postinstall.mjs→ correctly resolves tozero-v…-linux-arm64.tar.gz/ binaryzero.bin/zero.jszeroBinaryName()branches only win32-vs-else, so android maps to the plainzeroname postinstall installs — no runtime mismatch.internal/npmwrappertests pass; CI green incl. Windows smoke (no #414-class break).
Security: no new surface — download path unchanged (HTTPS-only pinned repo, SHA-256 verification against the release's own .sha256, no-zip-slip extraction). Android just selects an existing verified artifact.
Non-blocking follow-ups:
- Add an
android/arm64row to theTestPostinstallComputesAssetPlantable so a futureresolvePlatformrefactor can't silently re-break Termux (CodeRabbit flagged this too). - The optional linux sandbox helpers (
zero-linux-sandbox,zero-seccomp) are glibc/standard-kernel oriented and likely won't function under Termux's Bionic libc — so Zero runs with reduced isolation on Android. Behavior is already graceful (optional helpers + warning), but a Termux-specific "sandboxing unavailable" note would set correct expectations.
Approving.
Summary
npm install -g @gitlawb/zerofailed on Android/Termux withEBADPLATFORMbecausepackage.json'sosarray did not include"android". Termux provides a Linux userspace on the Linux kernel — the existinglinux-arm64binary works natively.Changes
package.json— Added"android"to theosarray.scripts/postinstall.mjs— MappedandroidtolinuxinresolvePlatform(), so the postinstall downloads the correctlinux-arm64binary.Verified by the reporter on Termux (Unihertz Titan 2, Android 11, aarch64): postinstall succeeds and
zero --helpruns correctly.Fixes #449
Summary by CodeRabbit