Skip to content

fix: scan nvm/fnm/volta dirs when binary not on PATH#317

Merged
zomux merged 1 commit intoopenagents-org:developfrom
Edison-A-N:fix/nvm-binary-discovery
Mar 19, 2026
Merged

fix: scan nvm/fnm/volta dirs when binary not on PATH#317
zomux merged 1 commit intoopenagents-org:developfrom
Edison-A-N:fix/nvm-binary-discovery

Conversation

@Edison-A-N
Copy link
Copy Markdown
Contributor

Summary

  • Problem: Non-interactive shells (daemons, systemd, launchd) don't source ~/.nvm/nvm.sh, so node version manager binaries (e.g. openclaw) aren't on PATH. shutil.which() returns None even though the binary is installed.
  • Fix: When shutil.which() fails in _which_binary(), fall back to scanning well-known node version manager directories: nvm (~/.nvm/versions/node/v*/bin), fnm (~/.local/share/fnm/node-versions/v*/installation/bin), and volta (~/.volta/bin). Prefers the newest node version.
  • Scope: Single change in src/openagents/registry/loader.py — no other files modified.

Non-interactive shells (daemons, systemd) lack nvm/fnm/volta in PATH.
Fall back to scanning well-known node version manager directories
when shutil.which() finds nothing, preferring the newest node version.
Copilot AI review requested due to automatic review settings March 19, 2026 16:15
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

@Edison-A-N is attempting to deploy a commit to the Raphael's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves agent binary discovery in openagents when running in non-interactive environments where Node version manager shims aren’t on PATH, by adding a fallback search for binaries installed under nvm/fnm/volta-managed directories.

Changes:

  • If shutil.which(binary) fails, scan nvm (~/.nvm/versions/node/v*/bin), fnm (~/.local/share/fnm/node-versions/v*/installation/bin), and volta (~/.volta/bin) for the requested binary.
  • Return the first matching executable found (intended to prefer the newest Node version).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +294 to +298
if fnm_dir.is_dir():
for d in sorted(fnm_dir.iterdir(), reverse=True):
c = d / "installation" / "bin" / binary
if c.is_file() and os.access(c, os.X_OK):
return str(c)
Comment on lines +288 to +298
for d in sorted(node_versions.iterdir(), reverse=True):
c = d / "bin" / binary
if c.is_file() and os.access(c, os.X_OK):
return str(c)
# fnm
fnm_dir = home / ".local" / "share" / "fnm" / "node-versions"
if fnm_dir.is_dir():
for d in sorted(fnm_dir.iterdir(), reverse=True):
c = d / "installation" / "bin" / binary
if c.is_file() and os.access(c, os.X_OK):
return str(c)
if c.is_file() and os.access(c, os.X_OK):
return str(c)
# volta
volta_bin = home / ".volta" / "bin" / binary
return found
# nvm
home = Path.home()
nvm_dir = Path(os.environ.get("NVM_DIR", home / ".nvm"))
Comment on lines +287 to +291
if node_versions.is_dir():
for d in sorted(node_versions.iterdir(), reverse=True):
c = d / "bin" / binary
if c.is_file() and os.access(c, os.X_OK):
return str(c)
Copy link
Copy Markdown
Contributor

@zomux zomux left a comment

Choose a reason for hiding this comment

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

LGTM. This fixes a real issue where non-interactive shells (daemons, systemd) can't find nvm/fnm/volta-installed binaries. Verified the nvm path pattern against a real installation. Good coverage of the three major node version managers.

Minor note: string sorting on directory names works for same-digit-count versions but could mis-order e.g. v9.x vs v20.x. Not a practical concern since modern Node versions are all 18+.

@zomux zomux merged commit 8521af6 into openagents-org:develop Mar 19, 2026
6 of 13 checks passed
@Edison-A-N Edison-A-N deleted the fix/nvm-binary-discovery branch March 20, 2026 00:22
Edison-A-N added a commit to Edison-A-N/openagents that referenced this pull request Mar 20, 2026
)

Non-interactive shells (daemons, systemd) lack nvm/fnm/volta in PATH.
Fall back to scanning well-known node version manager directories
when shutil.which() finds nothing, preferring the newest node version.
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.

3 participants