Skip to content

fix(cli): pick the first node >= 22 across all PATH entries#189

Open
arelchan wants to merge 1 commit into
mainfrom
fix/find_node_min_version_all_path
Open

fix(cli): pick the first node >= 22 across all PATH entries#189
arelchan wants to merge 1 commit into
mainfrom
fix/find_node_min_version_all_path

Conversation

@arelchan

@arelchan arelchan commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Change description

Fixes raven tui failing with a "Node version too low (found 20.20.1, need >= 22)" error on machines that do have a recent Node installed (e.g. Homebrew node 26), while raven agent works fine.

Two bugs in find_node() (raven/cli/tui_commands.py):

  1. No minimum-version filtering. It returned the first candidate whose --version merely parsed, regardless of _MIN_NODE_VERSION. The caller then rejected it if < 22 without ever asking for the next candidate -- so a too-old node in an earlier priority tier shadowed a valid newer one.
  2. PATH probed with shutil.which("node"), which returns only the first hit. A stale < 22 node earlier on PATH (an old /usr/local/bin/node, an nvm/asdf shim, etc.) hid a newer node later on PATH.

Together: a user with node 26 on PATH but a 20.x earlier on PATH got "node too low". raven agent was unaffected (no Node needed), which made it look like a TUI/streaming problem.

Fix

  • Enumerate every node on PATH (not just the first).
  • Return the first candidate that meets _MIN_NODE_VERSION, in priority order (RAVEN_NODE -> venv -> PATH -> private runtime).
  • Keep the highest below-minimum candidate so, when nothing qualifies, the caller still reports the real version (found 20.20.1, need >= 22) instead of a bare "not found".

Tests

Added to tests/test_cli_tui_bootstrap.py:

  • test_find_node_skips_below_min_and_scans_all_path -- a 20.20.1 earlier on PATH + a 26.5.0 later => find_node returns 26.5.0.
  • test_find_node_reports_below_min_when_nothing_qualifies -- only a 20.20.1 => returns it (so the caller can show the version).

Type of change

  • Bug fix
  • New feature
  • Document
  • Others

Checklists

Development

  • Lint rules pass locally (ruff check / ruff format)
  • Application changes have been tested thoroughly
  • Automated tests covering modified code pass

Code review

  • Pull request has a descriptive title and context useful to a reviewer

Note (unrelated, pre-existing)

test_find_node_discovers_windows_private_runtime fails on non-Windows hosts on main already (its mock sets sys.platform="win32" but find_node's Priority-4 branch keys off os.name == "nt"). It is not run by CI's make test-python subset, so CI stays green. Left untouched here to keep this PR scoped; flagging it for a separate fix.

find_node returned the first node it could run without checking the
minimum version, and probed PATH via shutil.which which yields only the
first hit. So a stale < 22 node earlier on PATH (an old /usr/local/bin
node or a version-manager shim) shadowed a newer node later on PATH (e.g.
homebrew node 26): the caller received the old version and errored with
'node too low' even though a usable node was installed. raven agent
worked (no node needed) while raven tui failed, which made it look like a
tui/streaming issue.

enumerate every node on PATH (not just the first) and return the first
candidate that meets the >= 22 minimum, in priority order; keep the
highest below-minimum candidate so the caller still reports the real
version instead of a bare not-found.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@arelchan
arelchan force-pushed the fix/find_node_min_version_all_path branch from e1bf1b7 to 042dd9d Compare July 22, 2026 14:59
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