From 9cb87a0d1c7015aeab09cf0d9068c7c7ede666ce Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 21 Apr 2026 12:16:04 +1000 Subject: [PATCH 1/3] feat: support HERMIT_PREPEND_PATH to prepend entries to PATH When HERMIT_PREPEND_PATH is set, its value is always prepended to the front of PATH after all other environment operations are applied. This allows users to ensure specific directories take precedence over Hermit-managed packages. Amp-Thread-ID: https://ampcode.com/threads/T-019dadd0-6b25-732a-b210-b45c6404515a Co-authored-by: Amp --- env.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/env.go b/env.go index 1d1600b1..0d847416 100644 --- a/env.go +++ b/env.go @@ -1429,6 +1429,9 @@ func (e *Env) allEnvarOpsForPackages(runtimeDeps []*manifest.Package, targetPkg } ops = append(ops, e.localEnvarOps()...) ops = append(ops, e.ephemeralEnvars...) + if prependPath := os.Getenv("HERMIT_PREPEND_PATH"); prependPath != "" { + ops = append(ops, &envars.Prepend{Name: "PATH", Value: prependPath}) + } return ops } From 760faf286883dbc437b5c63537db8e194e79fbd4 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 21 Apr 2026 14:52:20 +1000 Subject: [PATCH 2/3] test: add integration test for HERMIT_PREPEND_PATH Amp-Thread-ID: https://ampcode.com/threads/T-019dadd0-6b25-732a-b210-b45c6404515a Co-authored-by: Amp --- integration/integration_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration/integration_test.go b/integration/integration_test.go index 52eba852..545d21e5 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -673,6 +673,15 @@ EOF assert test "${CLEANUP_DONE:-}" = "yes" `, }, + { + name: "HermitPrependPathIsRespected", + preparations: prep{fixture("testenv1")}, + script: ` + export HERMIT_PREPEND_PATH="/prepend/first:/prepend/second" + . bin/activate-hermit + assert echo "$PATH" | grep -q "^/prepend/first:/prepend/second:" + `, + }, { name: "InstallOnActivateEnsuresPackagesAreUnpacked", preparations: prep{fixture("testenv-install-on-activate"), activate(".")}, From c7647b2e03ad1fea29e8057b33d38d1055895a35 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 21 Apr 2026 15:07:30 +1000 Subject: [PATCH 3/3] docs: document HERMIT_PREPEND_PATH environment variable Amp-Thread-ID: https://ampcode.com/threads/T-019dadd0-6b25-732a-b210-b45c6404515a Co-authored-by: Amp --- docs/docs/usage/envars.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/usage/envars.md b/docs/docs/usage/envars.md index 884a717c..61cc892a 100644 --- a/docs/docs/usage/envars.md +++ b/docs/docs/usage/envars.md @@ -17,6 +17,7 @@ present in an active environment are: |-----------|------| | `HERMIT_ENV` | Path to the active Hermit environment. | | `HERMIT_BIN` | Path to the active Hermit environment `bin` directory. | +| `HERMIT_PREPEND_PATH` | If set, prepends its value to the front of `PATH` after all other environment operations are applied. Useful for ensuring specific directories always take precedence over Hermit-managed packages. | An empty environment might look something like the following: