From 013e10be29d749044c05152909fc802c9e6210a0 Mon Sep 17 00:00:00 2001 From: Alejandro Tamayo Date: Mon, 20 Apr 2026 16:37:40 +0200 Subject: [PATCH] fix(worktree): use login-shell PATH when running setup scripts Setup commands (bun install, etc.) failed in Electron GUI launches because process.env.PATH is stripped. Resolve the full shell env via getShellEnvironment() before exec(), matching the pattern already used by getGitEnv() in worktree.ts. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/main/lib/git/worktree-config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/lib/git/worktree-config.ts b/src/main/lib/git/worktree-config.ts index 40112cc2b..b2171bc4a 100644 --- a/src/main/lib/git/worktree-config.ts +++ b/src/main/lib/git/worktree-config.ts @@ -2,6 +2,7 @@ import { readFile, writeFile, mkdir, access } from "node:fs/promises" import { join, dirname, isAbsolute } from "node:path" import { exec } from "node:child_process" import { promisify } from "node:util" +import { getShellEnvironment } from "./shell-env" const execAsync = promisify(exec) @@ -206,6 +207,11 @@ export async function executeWorktreeSetup( console.log(`[worktree-setup] Running ${commandList.length} setup commands in ${worktreePath}`) + // Resolve the user's login-shell PATH so commands like `bun`, `pnpm`, homebrew + // binaries etc. are found when the app is launched from Finder/Dock (Electron + // GUI processes inherit a stripped PATH). + const shellEnv = await getShellEnvironment() + // Execute each command for (const cmd of commandList) { if (!cmd.trim()) continue @@ -217,6 +223,8 @@ export async function executeWorktreeSetup( cwd: worktreePath, env: { ...process.env, + ...shellEnv, + PATH: shellEnv.PATH ?? process.env.PATH, ROOT_WORKTREE_PATH: mainRepoPath, }, timeout: 300_000, // 5 minutes per command