Skip to content

fix(install): skip npm link when the installer runs from the global npm install - #1231

Merged
Fmarzochi merged 3 commits into
mainfrom
fix/install-skip-npm-link-global
Aug 8, 2026
Merged

fix(install): skip npm link when the installer runs from the global npm install#1231
Fmarzochi merged 3 commits into
mainfrom
fix/install-skip-npm-link-global

Conversation

@Fmarzochi

@Fmarzochi Fmarzochi commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • egc install run from the globally installed npm package no longer attempts npm link there: the guard resolves $(npm root -g)/@egchq/egc and compares it with the installer root (symlink-safe on both sides via pwd -P / Resolve-Path); on match it prints egc command already provided by the global npm install instead of failing with a note about a checkout the user does not have
  • Git checkouts and unpacked tarballs keep the exact previous behavior: npm link plus the best-effort fallback note
  • Structural tests added on both installers, parity-checked in install-ps1.test.js so install.sh and install.ps1 cannot drift apart on this guard

Why

The v1.1.18 Linux testing round (#1218) reproduced this on Ubuntu 26.04 with distro-packaged Node 22 (root-owned global prefix, sudo npm install -g): the install succeeds and the egc bin works, but the log ends with a scary npm link failed note pointing at a nonexistent checkout. The link step only makes sense when the installer runs from a tree that is not the global install itself.

Credit

Reported by @rathaur-ankit in #1218 with a precise environment description and screenshot (Ubuntu 26.04 LTS, distro Node 22 with npm 9, zsh, sudo global prefix): his second Linux testing report for EGC, after authoring the German README translation (#972).

Testing

  • bash -n scripts/install.sh passes
  • node tests/scripts/install-sh.test.js: 7/7, including the new guard case
  • node tests/scripts/install-ps1.test.js: 10/10, including the new parity case (PowerShell execution paths skipped on Linux as usual)

…pm install

`egc install` after `npm install -g @egchq/egc` executes the installer
from inside the global npm prefix, where npm link is redundant: the egc
bin on PATH already points at that tree. With a root-owned global prefix
(distro Node installed with sudo) the link step could only fail and
print a note telling the person to run commands "from this checkout"
when they do not have one (#1218 Linux report, Ubuntu 26.04 with distro
Node 22 and npm 9).

Both installers now resolve the global package directory (npm root -g)
and compare it against their own root before attempting the link: equal
means the global install already provides the command, and the step is
announced as skipped. Anything else keeps the previous npm link behavior
for git checkouts and unpacked tarballs. The comparison resolves
symlinks on both sides (pwd -P and Resolve-Path), so nvm/mise-style
symlinked prefixes still compare equal. Covered by structural tests on
both installers, parity-checked so install.sh and install.ps1 cannot
drift.

Reported-by: ankit <rathaurankit501@gmail.com>
Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
…ed (#1231)

Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
Signed-off-by: Felipe Marzochi <fmarzochi@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

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