Skip to content

Commit e39fa01

Browse files
committed
fix: handle missing ~/.claude directory and canonicalization errors gracefully
1 parent d9859ac commit e39fa01

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src-tauri/src/commands/claude.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,24 @@ fn find_claude_binary(app_handle: &AppHandle) -> Result<String, String> {
137137

138138
/// Gets the path to the ~/.claude directory
139139
fn get_claude_dir() -> Result<PathBuf> {
140-
dirs::home_dir()
140+
let claude_path = dirs::home_dir()
141141
.context("Could not find home directory")?
142-
.join(".claude")
143-
.canonicalize()
144-
.context("Could not find ~/.claude directory")
142+
.join(".claude");
143+
144+
// First check if the directory exists
145+
if !claude_path.exists() {
146+
return Err(anyhow::anyhow!("~/.claude directory does not exist"));
147+
}
148+
149+
// Try to canonicalize, but fall back to the original path if it fails
150+
match claude_path.canonicalize() {
151+
Ok(canonical_path) => Ok(canonical_path),
152+
Err(_) => {
153+
// If canonicalize fails but the directory exists, use the original path
154+
log::warn!("Could not canonicalize ~/.claude path, using original path");
155+
Ok(claude_path)
156+
}
157+
}
145158
}
146159

147160
/// Gets the actual project path by reading the cwd from the first JSONL entry

0 commit comments

Comments
 (0)