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.