Skip to content

fix: resolve symlinks in launcher script for npm global install#6

Merged
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-npm-launcher
Mar 23, 2026
Merged

fix: resolve symlinks in launcher script for npm global install#6
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-npm-launcher

Conversation

@simongdavies
Copy link
Contributor

The shell launcher used ${0%/} to find its lib/ directory, but when npm installs globally it creates a symlink in the bin dir. ${0%/} resolves to the npm bin dir, not the package dir, causing:
Cannot find module '.../lib/hyperagent-launcher.cjs'

Use readlink -f / realpath to resolve symlinks before computing the relative path to the lib directory.

Tested: symlink from /tmp/ → prints version correctly; old approach confirmed to fail with MODULE_NOT_FOUND.

Copilot AI review requested due to automatic review settings March 23, 2026 21:59
Copy link
Contributor

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

Updates the binary build process to generate a Unix shell launcher that can locate the packaged lib/ directory correctly even when the executable is installed as an npm global symlink (common for npm i -g).

Changes:

  • Update the generated Unix launcher to resolve symlinks (via readlink -f / realpath) before computing the path to lib/hyperagent-launcher.cjs.

The shell launcher used ${0%/*} to find its lib/ directory, but when
npm installs globally it creates a symlink in the bin dir. ${0%/*}
resolves to the npm bin dir, not the package dir, causing:
  Cannot find module '.../lib/hyperagent-launcher.cjs'

Use readlink -f / realpath to resolve symlinks before computing the
relative path to the lib directory.

Tested: symlink from /tmp/ → prints version correctly; old approach
confirmed to fail with MODULE_NOT_FOUND.

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies merged commit 76f5c0f into hyperlight-dev:main Mar 23, 2026
8 checks passed
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.

2 participants