From e39fa01c585ff68880a2476c3c2ba785e2ef2f4f Mon Sep 17 00:00:00 2001 From: ollieb89 Date: Thu, 11 Sep 2025 02:17:04 +0200 Subject: [PATCH] fix: handle missing ~/.claude directory and canonicalization errors gracefully --- src-tauri/src/commands/claude.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/commands/claude.rs b/src-tauri/src/commands/claude.rs index 94ad3c55..bd372bfe 100644 --- a/src-tauri/src/commands/claude.rs +++ b/src-tauri/src/commands/claude.rs @@ -137,11 +137,24 @@ fn find_claude_binary(app_handle: &AppHandle) -> Result { /// Gets the path to the ~/.claude directory fn get_claude_dir() -> Result { - dirs::home_dir() + let claude_path = dirs::home_dir() .context("Could not find home directory")? - .join(".claude") - .canonicalize() - .context("Could not find ~/.claude directory") + .join(".claude"); + + // First check if the directory exists + if !claude_path.exists() { + return Err(anyhow::anyhow!("~/.claude directory does not exist")); + } + + // Try to canonicalize, but fall back to the original path if it fails + match claude_path.canonicalize() { + Ok(canonical_path) => Ok(canonical_path), + Err(_) => { + // If canonicalize fails but the directory exists, use the original path + log::warn!("Could not canonicalize ~/.claude path, using original path"); + Ok(claude_path) + } + } } /// Gets the actual project path by reading the cwd from the first JSONL entry