Repository navigation
feat: run activated binaries through direct links - #630
Merged
Merged
Conversation
Each bin/ stub starts a Hermit process before running the real binary, adding roughly 150ms to every command in an activated shell. Activation now builds a per-environment directory of symlinks straight to the unpacked package binaries and puts it on PATH just ahead of bin/. Anything not linked falls through to its stub. Packages that need exec-time work keep their stubs: unpacked-on-first-use packages, exec triggers, runtime dependencies, bundled Hermit environments, and parent environments, whose stubs apply the parent's own variables. Link directories are named by a hash of their links and never change, so a shell's PATH always matches the package set its variables came from. They are only deleted by "hermit clean", because bash caches command paths and fails rather than searching PATH again. Activation also checks linked channel packages for updates, as their stubs no longer run. 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.
Every command in an activated Hermit shell goes through a
bin/stub, which starts a Hermit process to resolve the package, check for updates, and set up the environment before running the real binary. That costs roughly 150ms per invocation (measured withjust --version: ~0.15–0.18s through the stub versus under 0.01s for the binary itself), which adds up quickly in builds and scripts that call tools repeatedly.This change makes activation build a per-environment directory of symlinks pointing straight at unpacked package binaries, and puts it on
PATHdirectly ahead ofbin/. Anything without a link falls through to its stub, so behaviour is unchanged for those binaries.<state>/environments/<env-name>-<env-path-hash>/<links-hash>. The directory name is a hash of the links themselves, so packages whose contents change under the same reference (channels) still get a new directory.on exectriggers, runtime dependencies, or a bundled Hermit environment, and all packages from inherited parent environments (their stubs apply the parent's own variables, which the child's shell variables may override).PATHentry therefore always matches the package set its environment variables came from. A package change creates a new directory, and the existing prompt hooks switch the shell over at the next prompt.hermit clean. Deleting them on package changes would break running shells and processes: bash caches resolved command paths and fails with "No such file or directory" rather than searchingPATHagain.hermit clean --binremoves the current environment's directories, and--packages/--transientremove all of them.hermit activateandhermit env --activatecreate the directory.hermit env --opsonly computes its path. Activation also checks linked channel packages for updates, because their stubs no longer run to do it.update_hermit_pathnow includes the newHERMIT_LINK_FARMentry, so it stays directly ahead ofbin/.Known gaps:
bin/changes.hermit upgrade foo && foo, still use the previous links until the next prompt. That matches how other packages' environment variables already behave.Tests: unit tests in
linkfarm_test.gocover which packages get linked, thatEnvOpshas no side effects, that an upgrade leaves the old directory unchanged, and both clean options. New integration tests, run under bash and zsh, cover:on exectrigger packages keeping their stubsThe two zsh
PATH-order tests were updated for the new entry. Fish is not covered locally.🤖 Generated with Claude Code