Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/usage/envars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 3 additions & 0 deletions env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 9 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")},
Expand Down