Repository navigation
fix(shims): skip every shims directory when looking for the host tool - #19
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In local mode (
NODE_SHIMS_MODE=local/NODE_SHIMS_LOCAL=1) and in the host-node fallback for scripts outside the project,exec_locallooked up the tool onPATHwith only its own shims directory removed. Two setups make it loop forever, pegging a CPU:PATH(another clone or a git worktree): shim A skips A, finds B'snodeand execs it; B skips B, finds A's, and so onPATHdirectory (e.g.~/.local/bin/node -> .../bin/node): it is never skipped, even with a single shims directoryThis hung a smoke-test run for ~20 minutes during #17.
Changes
bin/common.sh:exec_localwalksPATHitself and skips any candidate whose real directory (symlinks followed) is a shims directory: this one, or any directory holdingcommon.shandnode-shell. With nothing left it prints the existing "not found outside the Docker shims" error.real_dir_of(symlink resolution withoutreadlink -f) andis_shims_dir.timeout 20so a regression fails instead of hanging CI.Testing
shellcheck -S warning bin/common.shbats test/unitinubuntu:24.04(as CI), 44/44/bin/bash3.2:PATH=<this worktree>/bin:<other clone>/bin:...:<nvm node>/bin NODE_SHIMS_MODE=local node -p process.versionreturnsdarwin v26.13.1immediately (previously hung)🤖 Generated with Claude Code