fix(install): preserve pip entry point when re-running on symlinked install#22472
Closed
wesleysimplicio wants to merge 2 commits into
Closed
fix(install): preserve pip entry point when re-running on symlinked install#22472wesleysimplicio wants to merge 2 commits into
wesleysimplicio wants to merge 2 commits into
Conversation
…nstall Re-running scripts/install.sh on a system installed under an older layout destroys the pip-generated venv/bin/hermes entry point and replaces it with a self-recursing bash shim, so 'hermes' hangs on every invocation. Cause: setup_path() writes the launcher with 'cat > "$command_link_dir/hermes"'. On a prior install $command_link_dir/hermes is a symlink pointing at venv/bin/hermes. The redirect follows the symlink and overwrites the pip entry point with the shim body. $HERMES_BIN then resolves to the same path, and exec calls itself. Fix: 'rm -f' the destination before the heredoc so the shim is created as a regular file in $command_link_dir, leaving the venv entry point intact. No restructuring of setup_path() — smallest change that captures the diagnosis. Adds tests/test_install_sh_symlink_stomp.py with a static guard (rm precedes the heredoc) and a behavioural reproducer that pre-creates the symlinked layout, drives the real shim-write block extracted from install.sh, and asserts venv/bin/hermes survives. Closes NousResearch#21513 Refs NousResearch#21454
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in scripts/install.sh where re-running the installer on a legacy (symlink-based) install layout could overwrite the pip-generated venv/bin/hermes entry point with a self-recursing shim, causing hermes to hang.
Changes:
- Remove any pre-existing
$command_link_dir/hermesbefore writing the shim heredoc to avoid following legacy symlinks. - Add regression tests that (1) statically guard ordering (
rm -fbefore heredoc) and (2) reproduce the symlink-stomp scenario and assert the venv entry point survives.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/install.sh | Deletes an existing hermes path in the command link dir before writing the launcher shim, preventing symlink-follow overwrite of the venv entry point. |
| tests/test_install_sh_symlink_stomp.py | Adds static + behavioral regression coverage for the legacy symlink overwrite / infinite loop shim scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Remove any prior entry first: on systems that installed an older layout | ||
| # ($command_link_dir/hermes was a symlink to venv/bin/hermes), `cat >` | ||
| # follows the symlink and overwrites the pip-generated entry point with | ||
| # the shim body, producing a self-execing wrapper that hangs on every |
Comment on lines
+70
to
+74
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| command_link_dir={command_link_dir!s} | ||
| HERMES_BIN={venv_entry!s} | ||
| {block} |
Collaborator
This was referenced May 12, 2026
Contributor
|
Superseded by #25734, which merged @Tranquil-Flow's earlier #21513 with the same one-line |
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.
Summary
Re-running
scripts/install.shon a system installed under an older layout destroys the pip-generatedvenv/bin/hermesentry point and replaces it with a self-recursing bash shim, sohermeshangs on every invocation.Cause
setup_path()writes the launcher withcat > "$command_link_dir/hermes". On a prior install$command_link_dir/hermesis a symlink pointing atvenv/bin/hermes. The redirect follows the symlink and overwrites the pip entry point with the shim body.$HERMES_BINthen resolves to the same path —execcalls itself.Fix
rm -fthe destination before the heredoc so the shim is created as a regular file in$command_link_dir, leaving the venv entry point intact. No restructuring ofsetup_path()— smallest change that captures the diagnosis.Changes
scripts/install.sh— addedrm -f "$command_link_dir/hermes"before thecat >heredoc.tests/test_install_sh_symlink_stomp.py— new file:rmprecedes the heredoc (and follows themkdir).install.sh, and assertsvenv/bin/hermessurvives.Test plan
./scripts/run_tests.sh tests/test_install_sh_symlink_stomp.py -v— both tests pass with fix.git stash push scripts/install.sh→ both tests fail (static guard missesrm; behavioural test sees pip body replaced by shim).git stash poprestores fix and tests pass again.bash -n scripts/install.shclean.Closes #21513
Refs #21454
🤖 Generated with Claude Code