Skip to content

fix(update): verify uv binary can execute before using it on Termux#35292

Closed
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/termux-uv-executability-check
Closed

fix(update): verify uv binary can execute before using it on Termux#35292
alaamohanad169-ship-it wants to merge 1 commit into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/termux-uv-executability-check

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Problem

On Android/Termux, the uv binary exists at the expected path and is found by shutil.which("uv"), but it cannot execute — it's an ELF built for Linux with dynamic linker /lib/ld-linux-aarch64.so.1 which doesn't exist on Android.

hermes update then fails with:

FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/usr/bin/uv'

Fix

Probe uv --version before using it at all three call sites:

  • _update_via_zip() — standalone ZIP installer path
  • _cmd_update_impl() — main hermes update path
  • _ensure_uv_for_termux() — uv bootstrap helper

On OSError, CalledProcessError, or TimeoutExpired, fall back to pip with a clear message.

Testing

Verified on Termux/Android (aarch64, Python 3.13): hermes update completes cleanly with an incompatible uv binary present.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels May 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Respin of #35287 (closed) by same author — stripped to just the uv binary probe fix, dropping the NODE_ENV=production change. Same Termux series as #23579, #19841, #27263.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: PR #35292 — fix(update): verify uv binary can execute before using it on Termux

Verdict: APPROVED ✅

Summary

This PR addresses a real bug on Android/Termux where shutil.which("uv") returns a path for a binary that exists on disk but cannot execute (wrong ELF dynamic linker). The fix probes each uv_bin with uv --version before using it, falling back to pip if the binary fails.

Checklist

Criterion Verdict Notes
Correctness Covers all three call sites (_update_via_zip, _ensure_uv_for_termux, _cmd_update_impl). The three exception types (OSError, CalledProcessError, TimeoutExpired) cover the failure modes of a non-executable ELF.
Security capture_output=True, no shell injection surface, 10-second timeout prevents hangs.
Code Quality Clear error messages ("→ uv found at {uv_bin} but cannot execute — falling back to pip"). Minor duplication (identical 9-line block × 3), but acceptable for a focused bugfix — a follow-up DRY refactor to a shared helper would be welcome.
Testing Manually verified on Termux/Android. A programmatic test for a non-executable binary would be fragile (needs permission trickery or LD loader manipulation).
Performance One extra subprocess call per update path (~50ms). Negligible.
Edge Cases Handles: uv_bin=None (early guard), existing but broken ELF (OSError), wrong-architecture binary (CalledProcessError), hung binary (TimeoutExpired).

One Suggestion (non-blocking)

Consider extracting the probe into a helper function:

def _probe_uv(uv_bin: str | None) -> str | None:
    if uv_bin:
        try:
            subprocess.run([uv_bin, "--version"], capture_output=True, timeout=10, check=True)
        except (OSError, subprocess.CalledProcessError, subprocess.TimeoutExpired):
            uv_bin = None
    return uv_bin

This reduces the three identical blocks to uv_bin = _probe_uv(uv_bin) each. Not required for merge — the current fix is functionally correct.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approve

👍 Looks Good

  • Fix correctly addresses the Termux/Android issue where uv binary exists but can't execute (wrong ELF linker)
  • Probe pattern (uv --version with subprocess.run) is applied consistently at all three UV call sites
  • Clean fallback to pip with clear user-facing message on each path
  • Exception coverage is thorough: OSError, CalledProcessError, and TimeoutExpired all handled
  • Uses capture_output=True and timeout=10 — no side effects, no hanging
  • The same pattern is applied in _update_via_zip, _ensure_uv_for_termux, and _cmd_update_impl — proper DRY within the fix
  • No new dependencies or config changes needed

💡 Minor Suggestion (not blocking)

  • The three probe blocks are identical — consider extracting a helper like _can_execute_uv(uv_bin: str) -> bool to keep the code DRY across all three call sites. This is minor and can be done in a follow-up.

✅ Verified

  • Single-commit PR (+32 lines in hermes_cli/main.py)
  • Only the uv executability check commit (f38bdf469) is the PR's unique contribution
  • Logic does not break the existing uv_bin flow on normal platforms

Reviewed by Hermes Agent

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🤖 Merge Request

This PR has been:

  • ✅ Reviewed and APPROVED by @tonydwb
  • ✅ All 15 CI checks passing
  • ✅ Mergeable with no conflicts

Could a maintainer please merge? 🙏

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

@teknium1 — this Termux fix has been approved by @tonydwb, all CI green, mergeable. Just needs a merge. Small focused fix — verified uv binary can execute before using it on Termux. Would you mind merging? 🙏

@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the fix/termux-uv-executability-check branch from f38bdf4 to b625bef Compare June 3, 2026 01:07
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

🔁 Rebased onto latest origin/main — was 298 commits behind, now clean.\n\n✅ 2 approvals, CI should re-trigger shortly. Ready for merge when green.

@alaamohanad169-ship-it alaamohanad169-ship-it deleted the fix/termux-uv-executability-check branch June 6, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants