fix(install): preserve pip entry point when re-running on symlinked install#25734
Merged
Conversation
…nstall setup_path() writes the user-facing hermes shim with `cat >`, which follows existing symlinks. Older installs created `$command_link_dir/hermes` as a symlink to `$HERMES_BIN` (`venv/bin/hermes`), so re-running install.sh stomped the pip entry point with a bash shim that exec'd itself in an infinite loop. `rm -f` the link target before writing so the shim lands at `$command_link_dir/hermes` and the venv entry point is left intact. Adds a regression test that reproduces the symlink-stomp end-to-end (creates the symlink, drives the real shim-write block from setup_path, asserts the venv pip script body survives and the shim is now a regular file). Both new assertions fail on origin/main and pass with the fix. Closes #21454.
This was referenced May 14, 2026
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/test_install_sh_symlink_stomp.py:23: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 4382 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced May 14, 2026
1 task
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.
Re-running
scripts/install.shon a system installed with an older layout overwrites the pip-generatedvenv/bin/hermesconsole script with a self-execing bash wrapper, sohermeshangs silently with no output.Root cause
setup_path()writes the user-facing launcher withcat > "$command_link_dir/hermes" <<EOF. Older installs created$command_link_dir/hermesas a symlink to$HERMES_BIN(venv/bin/hermes). The redirect follows the symlink and overwrites the pip entry point with the wrapper body.$HERMES_BINthen resolves to the same wrapper —execcalls itself, infinite loop.This is the trigger behind the recursive-wrapper hang reported across #21802, #21454, #21513, and #24834.
Fix
One-line:
rm -f "$command_link_dir/hermes"before thecat >heredoc, so the redirect always creates a fresh regular file and never follows a symlink back into the venv.Salvage attribution
Cherry-picked from @Tranquil-Flow's #21513. Three contributors independently converged on this exact one-line fix — credit also to @wesleysimplicio (#22472) and @luyao618 (#24850).
Validation
venv/bin/hermessurvives re-install~/.local/bin/hermesafter installhermesinvocationConfirmed live by reproducing the symlink-stomp end-to-end against the actual shim block in install.sh: pre-fix overwrites the pip entry point, post-fix leaves it intact.
Pinned by @Tranquil-Flow's regression test
tests/test_install_sh_symlink_stomp.py(2/2 passing) — both a static guard thatrm -fprecedes the heredoc, and a behavioural reproducer that drives the real shim-write block.Closes
hermesentry-point when ~/.local/bin/hermes is a symlink #24834Supersedes #22472, #24850 (same fix, later submissions).