From 03eccc999fa7f862430a0a102803eab1f3f04332 Mon Sep 17 00:00:00 2001 From: John Kenyon Date: Mon, 7 Apr 2025 04:29:27 +0000 Subject: [PATCH] Fix XDG_RUNTIME_DIR dependency by adding fallback to temp directory --- common/src/paths.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/src/paths.rs b/common/src/paths.rs index 982425a..ae01d70 100644 --- a/common/src/paths.rs +++ b/common/src/paths.rs @@ -6,9 +6,17 @@ use xdg::BaseDirectories; /// Get the path to the Cypraea socket. pub fn socket_path() -> Result { - // Use XDG_RUNTIME_DIR if available, or fall back to a temporary directory - let xdg = BaseDirectories::new().context("Failed to initialize XDG base directories")?; - Ok(xdg.place_runtime_file("cypraea.sock")?) + // Try to use XDG_RUNTIME_DIR if available + if let Ok(xdg) = BaseDirectories::new() { + if let Ok(path) = xdg.place_runtime_file("cypraea.sock") { + return Ok(path); + } + } + + // Fallback to a temporary directory if XDG_RUNTIME_DIR is not set + let tmp_dir = std::env::temp_dir(); + let socket_path = tmp_dir.join("cypraea.sock"); + Ok(socket_path) } /// Get the path to the Cypraea database directory.