From 7256de34acbd0490fb1f06afbf4d7e5c1af93164 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Wed, 9 Apr 2025 13:25:58 +0300 Subject: [PATCH] fix: add 'fdfind' binary name --- src/dependencies.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/dependencies.rs b/src/dependencies.rs index a517cc8..895d953 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -2,6 +2,8 @@ use crate::errors::{ProjectFinderError, Result}; use tracing::info; use which::which; +const FD_PATH: [&str; 2] = ["fd", "fdfind"]; + /// Represents external dependencies required by the application. #[derive(Debug, Clone)] pub struct Dependencies { @@ -27,16 +29,23 @@ impl Dependencies { pub fn check() -> Result { info!("Checking dependencies..."); - let fd_path = which("fd") - .map(|path| path.to_string_lossy().into_owned()) - .map_err(|_| { + let fd_path = FD_PATH + .iter() + .find_map(|binary| { + if let Ok(path) = which(binary) { + let fd_path = path.to_string_lossy().into_owned(); + info!("Found {binary} at: {}", fd_path); + return Some(fd_path); + } + None + }) + .ok_or_else(|| { ProjectFinderError::DependencyNotFound( - "fd - install from https://github.com/sharkdp/fd".into(), + "Neither 'fd' nor 'fdfind' was found. Please install fd from https://github.com/sharkdp/fd" + .into(), ) })?; - info!("Found fd at: {fd_path}"); - Ok(Self::new(fd_path)) } }