Skip to content

Commit 34886fd

Browse files
fix(shared): preserve Windows shell PATH priority
- Keep the user's shell PATH order ahead of known CLI fallback directories - Update Windows environment resolution coverage
1 parent 2daff8c commit 34886fd

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/shared/src/shell.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ effectIt.layer(NodeServices.layer)("resolveSpawnCommand", (it) => {
450450
});
451451

452452
effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
453-
it.effect("returns the baseline no-profile PATH patch when node is already available", () =>
453+
it.effect("uses known CLI directories as a fallback without changing shell PATH priority", () =>
454454
Effect.gen(function* () {
455455
const readEnvironment = vi.fn(
456456
(_names: ReadonlyArray<string>, options?: { loadProfile?: boolean }) =>
@@ -473,15 +473,15 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
473473
),
474474
).toEqual({
475475
PATH: [
476+
"C:\\Shell\\Bin",
477+
"C:\\Windows\\System32",
476478
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
477479
"C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
478480
"C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
479481
"C:\\Users\\testuser\\AppData\\Local\\pnpm",
480482
"C:\\Users\\testuser\\.local\\bin",
481483
"C:\\Users\\testuser\\.bun\\bin",
482484
"C:\\Users\\testuser\\scoop\\shims",
483-
"C:\\Shell\\Bin",
484-
"C:\\Windows\\System32",
485485
].join(";"),
486486
});
487487
expect(readEnvironment).toHaveBeenCalledTimes(1);
@@ -522,14 +522,14 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
522522
PATH: [
523523
"C:\\Profile\\Node",
524524
"C:\\Windows\\System32",
525+
"C:\\Shell\\Bin",
525526
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
526527
"C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
527528
"C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
528529
"C:\\Users\\testuser\\AppData\\Local\\pnpm",
529530
"C:\\Users\\testuser\\.local\\bin",
530531
"C:\\Users\\testuser\\.bun\\bin",
531532
"C:\\Users\\testuser\\scoop\\shims",
532-
"C:\\Shell\\Bin",
533533
].join(";"),
534534
FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
535535
FNM_MULTISHELL_PATH: "C:\\Users\\testuser\\AppData\\Local\\fnm_multishells\\123",
@@ -566,11 +566,11 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
566566
),
567567
).toEqual({
568568
PATH: [
569+
"C:\\Windows\\System32",
569570
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
570571
"C:\\Users\\testuser\\.local\\bin",
571572
"C:\\Users\\testuser\\.bun\\bin",
572573
"C:\\Users\\testuser\\scoop\\shims",
573-
"C:\\Windows\\System32",
574574
].join(";"),
575575
FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
576576
});

‎packages/shared/src/shell.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,9 @@ export const resolveWindowsEnvironment = Effect.fn("shell.resolveWindowsEnvironm
724724
}).PATH;
725725
const mergedPath = mergePathValues(shellPath, inheritedPath, "win32");
726726
const knownCliPath = resolveKnownWindowsCliDirs(env).join(WINDOWS_PATH_DELIMITER);
727-
const baselinePath = mergePathValues(knownCliPath, mergedPath, "win32");
727+
// Preserve the order a user's shell uses. These directories fill gaps when
728+
// desktop apps launch without the full interactive-shell PATH.
729+
const baselinePath = mergePathValues(mergedPath, knownCliPath, "win32");
728730
const baselinePatch: Partial<NodeJS.ProcessEnv> = baselinePath ? { PATH: baselinePath } : {};
729731
const baselineEnv = mergeWindowsEnv(env, baselinePatch);
730732

0 commit comments

Comments
 (0)