Skip to content

fix(cli): skip npm lifecycle scripts during agent-browser post-setup#48601

Open
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/browser-post-setup-ignore-scripts
Open

fix(cli): skip npm lifecycle scripts during agent-browser post-setup#48601
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/browser-post-setup-ignore-scripts

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds --ignore-scripts to the npm install command in _run_post_setup() to prevent agent-browser's postinstall script from replacing the global npm symlink with a local node_modules/ path that gets destroyed on the next hermes update.

Related Issue

Fixes #48521

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • hermes_cli/tools_config.py: Added --ignore-scripts flag to the npm install command in _run_post_setup() for the agent_browser/browserbase post-setup path. This prevents agent-browser's fixUnixSymlink() postinstall from overwriting the global npm symlink (e.g. /opt/homebrew/bin/agent-browser) to point at the local node_modules/ binary, which disappears on the next update.
  • tests/hermes_cli/test_tools_config.py: Added test_agent_browser_post_setup_passes_ignore_scripts — verifies that --ignore-scripts is present in the npm install command when _run_post_setup('agent_browser') runs.

How to Test

  1. Install agent-browser globally: npm install -g agent-browser@0.27.1
  2. Verify the global symlink points to the global install: ls -la $(which agent-browser) — should point to /opt/homebrew/lib/node_modules/agent-browser/...
  3. Run hermes update (or any command that triggers _run_post_setup("agent_browser"))
  4. Verify the global symlink is unchanged: ls -la $(which agent-browser) — should still point to the global install path
  5. Verify browser tools still work: agent-browser --version
  6. Run the regression test: python -m pytest tests/hermes_cli/test_tools_config.py::test_agent_browser_post_setup_passes_ignore_scripts -xvs

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Code Intelligence

⚠️ GitNexus unavailable — grep-based fallback used.

  • Checked files/symbols: _run_post_setup in hermes_cli/tools_config.py (callers: 4 call sites in tools_config.py)
  • Blast radius: LOW — only affects the npm install command in _run_post_setup, which is a setup/installation path
  • Related patterns: fixUnixSymlink() in agent-browser/scripts/postinstall.js is the upstream root cause; --ignore-scripts is the standard npm flag to suppress lifecycle scripts

agent-browser's postinstall script (fixUnixSymlink) replaces the global
npm symlink to point directly at the local node_modules/ binary.  When
hermes update reinstalls node_modules, that local path is destroyed,
leaving a dangling symlink that makes all browser tools unusable.

Adding --ignore-scripts to the npm install call in _run_post_setup()
prevents the postinstall from touching the global symlink while keeping
the local node_modules/ install intact (bin stubs are created by npm
regardless of lifecycle scripts, and the native binaries ship with the
package).

Fixes NousResearch#48521
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard tool/browser Browser automation (CDP, Playwright) P2 Medium — degraded but workaround exists labels Jun 18, 2026
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 P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hermes update 后 agent-browser 全局软链变成死链,导致 browser 工具失效(dangling symlink to internal path)

2 participants