-
Notifications
You must be signed in to change notification settings - Fork 876
fix(shell): bound PATH repair fallbacks #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,14 @@ | ||
| import { readPathFromLoginShell } from "@t3tools/shared/shell"; | ||
| import { | ||
| defaultShellCandidates, | ||
| resolvePathFromLoginShells, | ||
| shouldRepairPath, | ||
| } from "@t3tools/shared/shell"; | ||
|
|
||
| export function fixPath(): void { | ||
| if (process.platform !== "darwin") return; | ||
| if (!shouldRepairPath()) return; | ||
|
|
||
| try { | ||
| const shell = process.env.SHELL ?? "/bin/zsh"; | ||
| const result = readPathFromLoginShell(shell); | ||
| if (result) { | ||
| process.env.PATH = result; | ||
| } | ||
| } catch { | ||
| // Keep inherited PATH if shell lookup fails. | ||
| const result = resolvePathFromLoginShells(defaultShellCandidates()); | ||
| if (result) { | ||
| process.env.PATH = result; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,17 @@ | ||
| import * as OS from "node:os"; | ||
| import { Effect, Path } from "effect"; | ||
| import { readPathFromLoginShell } from "@t3tools/shared/shell"; | ||
| import { | ||
| defaultShellCandidates, | ||
| resolvePathFromLoginShells, | ||
| shouldRepairPath, | ||
| } from "@t3tools/shared/shell"; | ||
|
|
||
| export function fixPath(): void { | ||
| if (process.platform !== "darwin") return; | ||
| if (!shouldRepairPath()) return; | ||
|
|
||
| try { | ||
| const shell = process.env.SHELL ?? "/bin/zsh"; | ||
| const result = readPathFromLoginShell(shell); | ||
| if (result) { | ||
| process.env.PATH = result; | ||
| } | ||
| } catch { | ||
| // Silently ignore — keep default PATH | ||
| const resolvedPath = resolvePathFromLoginShells(defaultShellCandidates()); | ||
| if (resolvedPath) { | ||
| process.env.PATH = resolvedPath; | ||
| } | ||
|
Comment on lines
9
to
15
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runs a synchronous PATH repair on Linux as well as macOS; with the current 5s timeout and two invocation modes per shell, Electron main startup can block for up to ~30s in the worst case. Consider reducing the timeout and/or short-circuiting when PATH is already populated enough to resolve required binaries.