Skip to content

Commit 963fdfa

Browse files
authored
Merge pull request #106 from OpenAgentPlatform/mac-env
feat: try to get the system path in darwin if packaged
2 parents 2950584 + c23405a commit 963fdfa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

electron/main/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from "node:path"
55
import os from "node:os"
66
import AppState from "./state"
77
import { cleanup, initMCPClient } from "./service"
8-
import { getNvmPath, modifyPath } from "./util"
8+
import { getDarwinSystemPath, getNvmPath, modifyPath } from "./util"
99
import { binDirList, darwinPathList } from "./constant"
1010
import { update } from "./update"
1111
import { ipcHandler } from "./ipc"
@@ -57,6 +57,10 @@ async function onReady() {
5757
if (process.platform === "win32") {
5858
binDirList.forEach(modifyPath)
5959
} else if (process.platform === "darwin") {
60+
if (!process.env.PATH) {
61+
process.env.PATH = await getDarwinSystemPath().catch(() => "")
62+
}
63+
6064
darwinPathList.forEach(modifyPath)
6165

6266
const nvmPath = getNvmPath()

electron/main/util.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from "node:path"
33
import { spawn } from "cross-spawn"
44
import { app } from "electron"
55
import fse from "fs-extra"
6+
import { exec } from "node:child_process"
67

78
export function isPortInUse(port: number): Promise<boolean> {
89
return new Promise((resolve) => {
@@ -116,3 +117,15 @@ export function compareFilesAndReplace(filePath1: string, filePath2: string) {
116117
fse.copyFileSync(filePath1, filePath2)
117118
}
118119
}
120+
121+
export function getDarwinSystemPath(): Promise<string> {
122+
return new Promise((resolve, reject) => {
123+
exec("echo $PATH", (error, stdout, stderr) => {
124+
if (error) {
125+
reject(error)
126+
return
127+
}
128+
resolve(stdout.trim())
129+
})
130+
})
131+
}

0 commit comments

Comments
 (0)