diff --git a/Cargo.lock b/Cargo.lock index a682d69c..49cae84c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1450,6 +1450,7 @@ dependencies = [ "dirs 6.0.0", "dunce", "enclose", + "fix-path-env", "flate2", "fluent-uri", "futures", @@ -1894,6 +1895,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +[[package]] +name = "fix-path-env" +version = "0.0.0" +source = "git+https://github.com/tauri-apps/fix-path-env-rs?rev=c4c45d503ea115a839aae718d02f79e7c7f0f673#c4c45d503ea115a839aae718d02f79e7c7f0f673" +dependencies = [ + "home", + "strip-ansi-escapes", + "thiserror 1.0.69", +] + [[package]] name = "fixedbitset" version = "0.5.7" @@ -2535,6 +2546,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "homedir" version = "0.3.6" @@ -6096,6 +6116,15 @@ dependencies = [ "quote", ] +[[package]] +name = "strip-ansi-escapes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" +dependencies = [ + "vte", +] + [[package]] name = "strsim" version = "0.11.1" @@ -7517,6 +7546,15 @@ dependencies = [ "libc", ] +[[package]] +name = "vte" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" +dependencies = [ + "memchr", +] + [[package]] name = "walkdir" version = "2.5.0" diff --git a/electron/main/index.ts b/electron/main/index.ts index 3f2f23ba..d354ef53 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -3,7 +3,7 @@ import path from "node:path" import os from "node:os" import AppState from "./state" import { cleanup, initMCPClient } from "./service" -import { getDarwinSystemPath, modifyPath } from "./util" +import { getUnixSystemPath, modifyPath } from "./util" import { binDirList, darwinPathList, __dirname, VITE_DEV_SERVER_URL, RENDERER_DIST, logDir } from "./constant" import { update } from "./update" import { ipcHandler } from "./ipc" @@ -67,11 +67,11 @@ const indexHtml = path.join(RENDERER_DIST, "index.html") async function onReady() { if (process.platform === "win32") { binDirList.forEach(modifyPath) - } else if (process.platform === "darwin") { - if (!process.env.PATH) { - process.env.PATH = await getDarwinSystemPath().catch(() => "") - } + } else { + process.env.PATH = await getUnixSystemPath().catch(() => process.env.PATH) + } + if (process.platform === "darwin") { darwinPathList.forEach(modifyPath) } diff --git a/electron/main/util.ts b/electron/main/util.ts index 74ec6699..5ac72129 100644 --- a/electron/main/util.ts +++ b/electron/main/util.ts @@ -94,7 +94,7 @@ export function compareFilesAndReplace(filePath1: string, filePath2: string) { } } -export function getDarwinSystemPath(): Promise { +export function getUnixSystemPath(): Promise { return new Promise((resolve, reject) => { exec("echo $PATH", (error, stdout, stderr) => { if (error) { @@ -104,4 +104,4 @@ export function getDarwinSystemPath(): Promise { resolve(stdout.trim()) }) }) -} \ No newline at end of file +} diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 670678da..f7672a76 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -53,7 +53,7 @@ enclose = "1.2.1" which = "8.0.0" mime_guess = "2" fluent-uri = "0.4.1" -# dive-core = { workspace = true } +fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs", rev = "c4c45d503ea115a839aae718d02f79e7c7f0f673" } [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-autostart = "2" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b1805aaa..c5d1dd11 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,6 +3,8 @@ #[tokio::main] async fn main() { + let _ = fix_path_env::fix(); + // TODO: Remove this workaround when the tauri issue is resolved // tauri Issue: https://github.com/tauri-apps/tauri/issues/9394 #[cfg(target_os = "linux")]