Browse Source

fix(multiplexer): don't double-source ~/.zshenv for zsh launch

zsh sources ~/.zshenv unconditionally at startup for every session, so
the explicit source in buildShellLaunchArgs ran it a second time, causing
duplicate PATH entries / non-idempotent side-effects. Drop it and only
source .zshrc explicitly.
adikpb 2 tuần trước cách đây
mục cha
commit
c1c97fd0a4
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      src/multiplexer/shared.ts

+ 7 - 2
src/multiplexer/shared.ts

@@ -57,7 +57,8 @@ export function resolveOpencodeExecutable(): string {
  *
  * Mirrors OpenCode's own `Shell.args()` resolution:
  * - nu / fish: `<shell> -c <command>` (no login mode)
- * - zsh: login mode, sources zshenv/zshrc, then runs command
+ * - zsh: login mode; zsh sources ~/.zshenv automatically, then we source
+ *   .zshrc before running the command
  * - bash: login mode, sources bashrc, then runs command
  * - cmd: `cmd /c <command>`
  * - powershell: `pwsh -NoProfile -Command <command>`
@@ -77,11 +78,15 @@ export function buildShellLaunchArgs(command: string): string[] {
     return [shell, '-c', command];
   }
   if (name === 'zsh') {
+    // zsh sources ~/.zshenv unconditionally at startup (every session, login or
+    // not), so we must not source it again here. Only source .zshrc (login
+    // mode already implies this, but doing it explicitly keeps PATH/aliases
+    // consistent for the launched command).
     return [
       shell,
       '-l',
       '-c',
-      `[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true\n[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1\n${command}`,
+      `[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1\n${command}`,
     ];
   }
   if (name === 'bash') {