spacedriveapp/spacedrive · error · anyhow::Error
Could not determine home directory
Error message
Could not determine home directory
What it means
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.
Source
Thrown at apps/cli/src/domains/daemon/mod.rs:29
/// Check daemon auto-start status
Status,
}
pub async fn run(data_dir: PathBuf, instance: Option<String>, cmd: DaemonCmd) -> Result<()> {
match cmd {
DaemonCmd::Install => install_launchd_service(data_dir, instance).await,
DaemonCmd::Uninstall => uninstall_launchd_service(instance).await,
DaemonCmd::Status => check_launchd_status(instance).await,
}
}
#[cfg(target_os = "macos")]
async fn install_launchd_service(data_dir: PathBuf, instance: Option<String>) -> Result<()> {
use std::fs;
use std::io::Write;
let home =
dirs::home_dir().ok_or_else(|| anyhow::anyhow!("Could not determine home directory"))?;
let launch_agents_dir = home.join("Library/LaunchAgents");
// Create LaunchAgents directory if it doesn't exist
fs::create_dir_all(&launch_agents_dir)?;
// Determine plist filename based on instance
let plist_name = if let Some(ref inst) = instance {
format!("com.spacedrive.daemon.{}.plist", inst)
} else {
"com.spacedrive.daemon.plist".to_string()
};
let plist_path = launch_agents_dir.join(&plist_name);
// Get the current daemon binary path
let current_exe = std::env::current_exe()?;
let daemon_path = current_exe
.parent()
.ok_or_else(|| anyhow::anyhow!("Could not determine binary directory"))?View on GitHub (pinned to 6dfeccf211)
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.
Defensive patterns
Strategy: retry
Try / catch
// Bounded retry for transient connection drops during one-way sends.
let mut attempt = 0;
loop {
match transport.send(target_device, msg.clone()).await {
Ok(()) => break Ok(()),
Err(e) if e.to_string().contains("Failed to finish stream") && attempt < 3 => {
attempt += 1;
wait_for_device_connected(®istry, target_device).await;
}
Err(e) => break Err(e),
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unknown config key: {}
- Cannot set key: {}
- Could not determine binary directory
- Networking service not available
- File transfer protocol not registered
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/e447153a1b210ab4.
Report an issue: GitHub.