{"record":{"id":"e447153a1b210ab4","repo":"spacedriveapp/spacedrive","slug":"could-not-determine-home-directory","errorCode":null,"errorMessage":"Could not determine home directory","messagePattern":"Could not determine home directory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/daemon/mod.rs","lineNumber":29,"sourceCode":"\t/// Check daemon auto-start status\n\tStatus,\n}\n\npub async fn run(data_dir: PathBuf, instance: Option<String>, cmd: DaemonCmd) -> Result<()> {\n\tmatch cmd {\n\t\tDaemonCmd::Install => install_launchd_service(data_dir, instance).await,\n\t\tDaemonCmd::Uninstall => uninstall_launchd_service(instance).await,\n\t\tDaemonCmd::Status => check_launchd_status(instance).await,\n\t}\n}\n\n#[cfg(target_os = \"macos\")]\nasync fn install_launchd_service(data_dir: PathBuf, instance: Option<String>) -> Result<()> {\n\tuse std::fs;\n\tuse std::io::Write;\n\n\tlet home =\n\t\tdirs::home_dir().ok_or_else(|| anyhow::anyhow!(\"Could not determine home directory\"))?;\n\tlet launch_agents_dir = home.join(\"Library/LaunchAgents\");\n\n\t// Create LaunchAgents directory if it doesn't exist\n\tfs::create_dir_all(&launch_agents_dir)?;\n\n\t// Determine plist filename based on instance\n\tlet plist_name = if let Some(ref inst) = instance {\n\t\tformat!(\"com.spacedrive.daemon.{}.plist\", inst)\n\t} else {\n\t\t\"com.spacedrive.daemon.plist\".to_string()\n\t};\n\tlet plist_path = launch_agents_dir.join(&plist_name);\n\n\t// Get the current daemon binary path\n\tlet current_exe = std::env::current_exe()?;\n\tlet daemon_path = current_exe\n\t\t.parent()\n\t\t.ok_or_else(|| anyhow::anyhow!(\"Could not determine binary directory\"))?","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/daemon/mod.rs#L11-L47","documentation":"Returned by the sync transport when send.finish() on the opened p2p stream fails after the message bytes were already written. finish() signals end-of-stream on the outgoing direction; failure here almost always means the connection degraded between write and finish — the peer went away, the connection was closed, or a timeout/idle limit hit. The preceding write succeeded, so delivery is not guaranteed.","triggerScenarios":"Calling the one-way sync send (transport.rs send path) when the target device disconnects mid-transfer: process killed, network drop, NAT/relay path torn down, or the peer closed the stream right after reading the bytes.","commonSituations":"Remote device sleeping/lid-closed during sync; mobile client backgrounded; flaky links where writes buffer locally but the connection resets; long messages exceeding idle timeouts.","solutions":["Confirm the target device is still online and paired, then resend the sync message.","Treat finish-failure as 'delivery unconfirmed' — re-run the sync operation rather than assuming the peer got the data.","Check keepalive/idle timeout configuration on the p2p connection if this recurs on large transfers.","Enable debug logging (the code logs 'Sync message sent successfully' only after finish) to see how far transfers get."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Bounded retry for transient connection drops during one-way sends.\nlet mut attempt = 0;\nloop {\n    match transport.send(target_device, msg.clone()).await {\n        Ok(()) => break Ok(()),\n        Err(e) if e.to_string().contains(\"Failed to finish stream\") && attempt < 3 => {\n            attempt += 1;\n            wait_for_device_connected(&registry, target_device).await;\n        }\n        Err(e) => break Err(e),\n    }\n}","preventionTips":["Treat finish() failure as delivery-unconfirmed: idempotent message design or re-send with dedup keys.","Confirm peer connectivity immediately before large sync sends.","Tune stream idle/keepalive settings if drops correlate with large payloads."],"tags":["rust","networking","p2p","quic-stream","transient"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}