Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
import { execFileSync } from "child_process";
import { app, BrowserWindow, dialog, ipcMain, Menu, MenuItemConstructorOptions, nativeTheme, shell } from "electron";
import * as fs from "fs";
import { createWriteStream } from "fs";
import * as http from "http";
import * as https from "https";
import * as path from "path";

// Fix PATH for macOS: GUI-launched Electron apps (Finder/Dock) don't inherit the user's shell PATH.
// This reads the actual PATH from a login shell so tools like npm/pnpm can be found.
// Uses unique delimiters to extract PATH cleanly, ignoring any shell startup noise (banners, motd, etc.).
if (process.platform === "darwin") {
const defaultPath = process.env.PATH;
try {
const userShell = process.env.SHELL || "/bin/zsh";
const output = execFileSync(userShell, ["-ilc", 'printf "__PPTB_PATH_START__"; printenv PATH; printf "__PPTB_PATH_END__"'], {
encoding: "utf8",
timeout: 3000,
maxBuffer: 1024 * 1024,
});
const startDelimiter = "__PPTB_PATH_START__";
const endDelimiter = "__PPTB_PATH_END__";
const startIndex = output.indexOf(startDelimiter);
const endIndex = output.indexOf(endDelimiter, startIndex + startDelimiter.length);
if (startIndex !== -1 && endIndex !== -1) {
const extractedPath = output.slice(startIndex + startDelimiter.length, endIndex).trim();
if (extractedPath) {
process.env.PATH = extractedPath;
}
}
} catch {
// Restore default PATH on failure (timeout, shell error, etc.)
process.env.PATH = defaultPath;
}
}
import {
CONNECTION_CHANNELS,
DATAVERSE_CHANNELS,
Expand Down
Loading