From 7bf47f4c05a2b9dcad9862180bc2858062788014 Mon Sep 17 00:00:00 2001 From: anhtahaylove Date: Thu, 2 Jul 2026 01:08:20 +0700 Subject: [PATCH] Find user-local Unix binaries without stale fork history Unix users often install helper tools into ~/.local/bin, but the fallback dependency search only checked Homebrew and system directories. Adding the user-local bin directory to the shared Unix fallback keeps GUI-launched dependency detection aligned with common CLI install locations. Constraint: Keep this PR limited to dependency path resolution. Rejected: Port the larger path-resolution branch | it mixes unrelated packaging and UI changes. Confidence: high Scope-risk: narrow Directive: Keep dependency resolution changes inside the shared path helpers unless a tool needs a truly special install location. Tested: cargo fmt --check Tested: cargo test utils::path::tests --lib Tested: cargo check Not-tested: Manual Linux/macOS install with deno in ~/.local/bin. --- src-tauri/src/services/deno.rs | 26 +++++++++++++++++--------- src-tauri/src/utils/command.rs | 3 +-- src-tauri/src/utils/path.rs | 12 ++++++++++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/services/deno.rs b/src-tauri/src/services/deno.rs index 53505162..bdf74722 100644 --- a/src-tauri/src/services/deno.rs +++ b/src-tauri/src/services/deno.rs @@ -1,5 +1,7 @@ use crate::types::DenoStatus; -use crate::utils::{find_system_binary, unix_system_binary_dirs, CommandExt}; +#[cfg(not(windows))] +use crate::utils::unix_system_binary_dirs; +use crate::utils::{find_system_binary, CommandExt}; use std::path::PathBuf; use std::process::Stdio; use tauri::{AppHandle, Manager}; @@ -11,14 +13,20 @@ fn get_system_deno_path() -> Option { #[cfg(not(windows))] let binary_name = "deno"; - let mut fallback_dirs = Vec::new(); - - #[cfg(not(windows))] - { - let home = std::env::var("HOME").unwrap_or_default(); - fallback_dirs.push(PathBuf::from(home).join(".deno/bin")); - fallback_dirs.extend(unix_system_binary_dirs()); - } + let fallback_dirs = { + #[cfg(windows)] + { + Vec::new() + } + #[cfg(not(windows))] + { + let mut dirs = Vec::new(); + let home = std::env::var("HOME").unwrap_or_default(); + dirs.push(PathBuf::from(home).join(".deno/bin")); + dirs.extend(unix_system_binary_dirs()); + dirs + } + }; find_system_binary(binary_name, &fallback_dirs) } diff --git a/src-tauri/src/utils/command.rs b/src-tauri/src/utils/command.rs index bafa8f7b..ad49d37c 100644 --- a/src-tauri/src/utils/command.rs +++ b/src-tauri/src/utils/command.rs @@ -18,7 +18,6 @@ pub trait CommandExt { impl CommandExt for Command { #[cfg(windows)] fn hide_window(&mut self) -> &mut Self { - use std::os::windows::process::CommandExt as WinCommandExt; self.creation_flags(CREATE_NO_WINDOW); self } @@ -33,7 +32,7 @@ impl CommandExt for Command { impl CommandExt for std::process::Command { #[cfg(windows)] fn hide_window(&mut self) -> &mut Self { - use std::os::windows::process::CommandExt as WinCommandExt; + use std::os::windows::process::CommandExt as _; self.creation_flags(CREATE_NO_WINDOW); self } diff --git a/src-tauri/src/utils/path.rs b/src-tauri/src/utils/path.rs index 323bdc52..d9f99ab1 100644 --- a/src-tauri/src/utils/path.rs +++ b/src-tauri/src/utils/path.rs @@ -96,11 +96,19 @@ pub fn unix_system_binary_dirs() -> Vec { } #[cfg(not(windows))] { - vec![ + let mut dirs = Vec::new(); + + if let Some(home) = std::env::var_os("HOME") { + dirs.push(PathBuf::from(home).join(".local").join("bin")); + } + + dirs.extend([ PathBuf::from("/opt/homebrew/bin"), PathBuf::from("/usr/local/bin"), PathBuf::from("/usr/bin"), - ] + ]); + + dirs } }