fix(install): preserve pip entry point when re-running on symlinked install#21513
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(install): preserve pip entry point when re-running on symlinked install#21513Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
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 NousResearch#21454.
3 tasks
This was referenced May 12, 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.
What does this PR do?
Re-running
install.shon a system installed with an older version of the script destroys the pip-generatedvenv/bin/hermesentry point and replaces it with a self-recursing bash shim, sohermeshangs on every invocation.The cause is that
setup_path()writes the shim with acat >heredoc:On a prior install,
~/.local/bin/hermesis a symlink to~/.hermes/hermes-agent/venv/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.This PR adds a 1-line
rm -fbefore the heredoc so the shim is created as a regular file in$command_link_dir, leaving the venv entry point intact. The fix is the smallest change that captures the diagnosis — no restructuring ofsetup_path().Related Issue
Fixes #21454
Type of Change
Changes Made
scripts/install.sh— addedrm -f "$command_link_dir/hermes"before thecat >heredoc insetup_path()so the shim is a regular file, not written through a legacy symlink.tests/test_install_sh_symlink_stomp.py— new file. Two tests: a static guard that thermprecedes the heredoc, and a behavioural reproducer that pre-creates the symlinked prior-install layout, drives the real shim-write block extracted frominstall.sh, and assertsvenv/bin/hermessurvives.How to Test
python -m pytest tests/test_install_sh_symlink_stomp.py tests/test_install_sh_pythonpath_sanitization.py -v→ 4 passed.git stashthescripts/install.shchange, re-run pytest. The behavioural test fails with the pip script body replaced by the self-execing shim.git stash poprestores it.bash -n scripts/install.sh→ clean (no syntax regressions).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Test reproducing the bug on
origin/main(without the fix):Notes
cat >site ininstall.shwhose target could realistically pre-exist as a symlink to a user-writable path. The other heredoc (cat > "$HERMES_HOME/SOUL.md") is gated by a non-existence check and isn't affected.