Skip to content

fix(shims): skip every shims directory when looking for the host tool - #19

Merged
gpmayorga merged 1 commit into
mainfrom
fix/local-mode-shim-loop
Nov 28, 2026
Merged

gpmayorga merged 1 commit into
mainfrom
fix/local-mode-shim-loop

Conversation

@gpmayorga

Copy link
Copy Markdown
Owner

Problem

In local mode (NODE_SHIMS_MODE=local / NODE_SHIMS_LOCAL=1) and in the host-node fallback for scripts outside the project, exec_local looked up the tool on PATH with only its own shims directory removed. Two setups make it loop forever, pegging a CPU:

  • a second shims directory on PATH (another clone or a git worktree): shim A skips A, finds B's node and execs it; B skips B, finds A's, and so on
  • a symlink to a shim in another PATH directory (e.g. ~/.local/bin/node -> .../bin/node): it is never skipped, even with a single shims directory

This hung a smoke-test run for ~20 minutes during #17.

Changes

  • bin/common.sh: exec_local walks PATH itself and skips any candidate whose real directory (symlinks followed) is a shims directory: this one, or any directory holding common.sh and node-shell. With nothing left it prints the existing "not found outside the Docker shims" error.
  • New helpers real_dir_of (symlink resolution without readlink -f) and is_shims_dir.
  • Unit test covering a copied shims dir, a symlink to a shim, starting from the other copy, and the no-host-tool error, each under timeout 20 so a regression fails instead of hanging CI.

Testing

  • shellcheck -S warning bin/common.sh
  • New test fails without the fix (times out at the first assertion) and passes with it: bats test/unit in ubuntu:24.04 (as CI), 44/44
  • macOS, /bin/bash 3.2: PATH=<this worktree>/bin:<other clone>/bin:...:<nvm node>/bin NODE_SHIMS_MODE=local node -p process.version returns darwin v26.13.1 immediately (previously hung)
  • Smoke suite: not run locally (no change to the Docker path); CI will run it

🤖 Generated with Claude Code

Local mode (NODE_SHIMS_MODE=local) and the host-node fallback looked up
the tool on PATH with only this shims directory removed. With a second
shims directory on PATH (another clone or worktree), or a symlink to a
shim, each shim found the other and they exec'd each other forever.

Now the lookup walks PATH and skips any candidate whose real directory
is a shims directory (this one, or any with common.sh and node-shell),
following symlinks. With no host tool left it fails with the existing
"not found outside the Docker shims" error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gpmayorga
gpmayorga merged commit 1171019 into main Nov 28, 2026
5 checks passed
@gpmayorga
gpmayorga deleted the fix/local-mode-shim-loop branch November 28, 2026 15:40
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