Skip to content

Commit 2ae8604

Browse files
committed
Fix root-home managed path
Preserve '/' when a trusted home-scoped installation's regex prefix captures the filesystem root. Treating that empty capture as undefined dropped the synthesized /.local/bin from stable launch PATH values. Cover the authenticated '/' home through the public stable-launch path. No trust rules, non-root paths, configuration, or global state change. Signed-off-by: Bernardo Donadio <[email protected]>
1 parent e8e0046 commit 2ae8604

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎src/daemon/managed-path.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function homeScopedInstallationRoot(
2323
? /^(.*)\/(?:\.local|\.nvm|\.npm-global|\.npm-packages|\.volta|\.asdf|\.codex|\.claude)(?:\/|$)/
2424
: /^(.*)\/(?:\.nvm|\.npm-global|\.npm-packages|\.volta|\.asdf|\.codex|\.claude)(?:\/|$)/;
2525
const match = pattern.exec(directory);
26-
return match?.[1] || undefined;
26+
return match ? match[1] || sep : undefined;
2727
}
2828

2929
function canonicalPath(path: string): string | undefined {

‎test/daemon/managed-path.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ describe("managed daemon executable path", () => {
199199
);
200200
});
201201

202+
it("preserves a root-home stable synthesized bin", () => {
203+
expect(managedDaemonPathForStableLaunch(
204+
"/usr/bin/node",
205+
["/.local/lib/node_modules/@donadiosolutions/lcm/dist/lcm.mjs", "daemon", "start"],
206+
"/var/lib/lcm",
207+
"/",
208+
)).toBe(`/.local/bin:${SYSTEMD_DAEMON_PATH}`);
209+
});
210+
202211
it("accepts an implicit home authenticated by passwd realpath equality", () => {
203212
platformMocks.homedir.mockReturnValue("/home/alias");
204213
platformMocks.userInfo.mockReturnValue({

0 commit comments

Comments
 (0)