Skip to content

fix: harden install.sh against inherited Python env leakage#20680

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-575541ea
May 6, 2026
Merged

fix: harden install.sh against inherited Python env leakage#20680
teknium1 merged 2 commits into
mainfrom
hermes/hermes-575541ea

Conversation

@teknium1

@teknium1 teknium1 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Salvages the install.sh portion of #20466 onto current main. PR #20466 bundled three unrelated changes under a misleading title; this PR is the install.sh piece alone. The UI padding changes will come in a separate PR.

Summary

Sanitize inherited PYTHONPATH / PYTHONHOME during install, and replace the hermes symlink with a small launcher wrapper that clears them before exec. Prevents a fresh install from being silently overridden when the installer is run from a Python-driven session that has PYTHONPATH set.

Changes

  • scripts/install.sh: early unset PYTHONPATH / unset PYTHONHOME; replace ln -sf shim with a tiny bash wrapper that unsets both before exec "$HERMES_BIN" "\$@".
  • tests/test_install_sh_pythonpath_sanitization.py: grep-style regression tests covering install-time unset + wrapper contents.

Validation

  • bash -n scripts/install.sh — OK
  • scripts/run_tests.sh tests/test_install_sh_pythonpath_sanitization.py — 2/2 pass
  • Local E2E: generated the wrapper as install.sh does, invoked it with PYTHONPATH=/stale + PYTHONHOME=/fake set; fake HERMES_BIN saw both as unset and args were forwarded verbatim.

Notes

  • hermes doctor already tolerates a non-symlink at the command-link path (line 854 treats it as "exists (non-symlink)"), so the switch from symlink to wrapper doesn't break the existing doctor check.
  • hermes doctor --fix only re-creates symlinks, so a stale wrapper pointing to a moved venv wouldn't self-heal — same failure mode as a stale symlink, different error text. Not addressed here.

Credits @adybag14-cyber — cherry-picked onto current main with authorship preserved.

Closes part of #20466.

@teknium1 teknium1 merged commit a869a52 into main May 6, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-575541ea branch May 6, 2026 11:02
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants