diff --git a/bin/hermit.hcl b/bin/hermit.hcl index b429ec961..adce94e61 100644 --- a/bin/hermit.hcl +++ b/bin/hermit.hcl @@ -1 +1,6 @@ manage-git = true + +env = { + "CARGO_HOME": "${HOME}/.cache/berd/cargo-home", + "PATH": "${HOME}/.cache/berd/cargo-home/bin:${PATH}", +} diff --git a/scripts/release/tests/release-scripts.test.mjs b/scripts/release/tests/release-scripts.test.mjs index d9ca70af7..b9f2c2e73 100644 --- a/scripts/release/tests/release-scripts.test.mjs +++ b/scripts/release/tests/release-scripts.test.mjs @@ -128,6 +128,19 @@ describe("managed Goose build profile", () => { }); }); +describe("shared Cargo package cache", () => { + it("keeps Cargo dependency and binary paths stable across worktrees", async () => { + const hermitConfig = await readFile(join(repo, "bin/hermit.hcl"), "utf8"); + + expect(hermitConfig).toMatch( + /"CARGO_HOME": "\$\{HOME\}\/\.cache\/berd\/cargo-home"/, + ); + expect(hermitConfig).toMatch( + /"PATH": "\$\{HOME\}\/\.cache\/berd\/cargo-home\/bin:\$\{PATH\}"/, + ); + }); +}); + describe("Docker Linux build environment", () => { it("forwards host build configuration when Docker replaces the environment", async () => { const dir = await tempDir();