Skip to content

fix(cli): resolve symlink chain so global installs find the package dir (v2.8.1) - #12

Merged
aldegad merged 2 commits into
mainfrom
fix/global-install-symlink-resolution
Jun 19, 2026
Merged

fix(cli): resolve symlink chain so global installs find the package dir (v2.8.1)#12
aldegad merged 2 commits into
mainfrom
fix/global-install-symlink-resolution

Conversation

@aldegad

@aldegad aldegad commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Problem

npm i -g @aldegad/safedeps (and ~/.local/bin via the installer's --link-bin) put a file symlink at <prefix>/bin/safedeps. ${BASH_SOURCE[0]} kept that symlink path, so dirname/.. resolved to the node prefix and every command died at:

bin/safedeps: line 18: <prefix>/lib/providers/providers.sh: No such file or directory

Reproduced verbatim against the npm global layout. Hooks were unaffected (they run through the skill's directory symlink, where cd .../scripts && pwd already lands in the real repo).

Fix

Walk the symlink chain to the real script before deriving the repo dir — a portable readlink + cd -P loop (not readlink -f, which is non-portable on macOS). Zero-dep preserved.

Tests

  • Regression smoke test: invokes the CLI through an npm-style global file symlink (relative symlink + package under lib/node_modules). Verified it fails on the pre-fix bootstrap with the exact reported error and passes after.
  • npm test (smoke + e2e) green; shellcheck --severity=error clean.

Docs

  • ROADMAP: added the missing v2.8 section (v2.8.0 adversarial re-audit + this v2.8.1 fix); EN SSoT + KO mirror.
  • Logged pnpm/yarn lockfile audit as a v3 gap (safedeps audit is npm-lockfile-only → exit 2 on pnpm/yarn).

Version bumped 2.8.0 → 2.8.1 (package.json + bin/safedeps SSoT).

aldegad added 2 commits June 19, 2026 19:31
…ir (v2.8.0->2.8.1)

npm i -g (and ~/.local/bin via --link-bin) put a FILE symlink at
<prefix>/bin/safedeps; ${BASH_SOURCE[0]} kept the symlink path, so dirname/..
resolved to the node prefix and every command died at
`source <prefix>/lib/providers/providers.sh: No such file or directory`.
Walk the symlink chain to the real script before deriving the repo dir
(portable readlink loop, not readlink -f). Hooks unaffected (dir-symlink).

- smoke: regression test invoking the CLI through an npm-style global file
  symlink; fails on the pre-fix bootstrap, passes after
- ROADMAP: add v2.8 section (v2.8.0 re-audit + v2.8.1 fix); log pnpm/yarn
  lockfile audit as a v3 gap
@aldegad
aldegad merged commit 7a8bc31 into main Jun 19, 2026
2 checks passed
@aldegad
aldegad deleted the fix/global-install-symlink-resolution branch June 19, 2026 10:35
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