{"record":{"id":"f145d61a30decad3","repo":"spacedriveapp/spacedrive","slug":"failed-to-start-daemon","errorCode":null,"errorMessage":"Failed to start daemon: {}","messagePattern":"Failed to start daemon: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/main.rs","lineNumber":307,"sourceCode":"\t\t\t// Set working directory to current directory\n\t\t\tcommand.current_dir(std::env::current_dir()?);\n\n\t\t\tif foreground {\n\t\t\t\t// Foreground mode: inherit stdout/stderr so logs are visible\n\t\t\t\tprintln!(\"Starting daemon in foreground mode...\");\n\t\t\t\tprintln!(\"Press Ctrl+C to stop the daemon\");\n\t\t\t\tprintln!(\"═══════════════════════════════════════════════════════\");\n\n\t\t\t\tmatch command.status() {\n\t\t\t\t\tOk(status) => {\n\t\t\t\t\t\tif status.success() {\n\t\t\t\t\t\t\tprintln!(\"Daemon exited successfully\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn Err(anyhow::anyhow!(\"Daemon exited with error: {}\", status));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tErr(e) => {\n\t\t\t\t\t\treturn Err(anyhow::anyhow!(\"Failed to start daemon: {}\", e));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Background mode: redirect stdout/stderr to null\n\t\t\t\tcommand.stdout(std::process::Stdio::null());\n\t\t\t\tcommand.stderr(std::process::Stdio::null());\n\n\t\t\t\tmatch command.spawn() {\n\t\t\t\t\tOk(child) => {\n\t\t\t\t\t\tprintln!(\"Daemon started (PID: {})\", child.id());\n\n\t\t\t\t\t\t// Wait a moment for daemon to start up\n\t\t\t\t\t\ttokio::time::sleep(tokio::time::Duration::from_millis(500)).await;\n\n\t\t\t\t\t\t// Verify daemon is responding\n\t\t\t\t\t\tmatch client\n\t\t\t\t\t\t\t.send_raw_request(&sd_core::infra::daemon::types::DaemonRequest::Ping)\n\t\t\t\t\t\t\t.await","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/main.rs#L289-L325","documentation":"In 'sd start --foreground', command.status() itself returned Err: the sd-daemon binary could not be executed at all. Typical io::Error kinds: NotFound (sd-daemon missing next to sd), PermissionDenied (exec bit lost), Exec format error (wrong architecture), or InvalidInput.","triggerScenarios":"Only the sd CLI binary was installed; sd-daemon lost its executable bit after a copy; a binary built for a different target triple.","commonSituations":"Partial manual installs; extracting release tarballs without preserving modes; mixing builds across machines.","solutions":["Confirm sd-daemon exists beside the sd binary: ls $(dirname $(which sd))","chmod +x sd-daemon and retry","Reinstall a release build matching your platform, or cargo build both binaries from source"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"#!/usr/bin/env bash\nbin_dir=$(dirname \"$(command -v sd)\")\n[ -x \"$bin_dir/sd-daemon\" ] || { echo \"sd-daemon missing or not executable in $bin_dir\" >&2; exit 2; }\nsd start --foreground","typeGuard":"fn daemon_executable(bin_dir: &std::path::Path) -> Option<std::path::PathBuf> {\n    let p = bin_dir.join(\"sd-daemon\");\n    p.is_file().then(|| p).filter(|p| p.metadata().map(|m| m.permissions().mode() & 0o111 != 0).unwrap_or(false))\n}","tryCatchPattern":"if let Err(e) = command.status() {\n    let hint = match e.kind() {\n        std::io::ErrorKind::NotFound => \"sd-daemon not found next to the sd binary\",\n        std::io::ErrorKind::PermissionDenied => \"run chmod +x sd-daemon\",\n        _ => \"check architecture/exec format of sd-daemon\",\n    };\n    anyhow::bail!(\"Failed to start daemon: {} ({})\", e, hint);\n}","preventionTips":["Install sd and sd-daemon together from the same release into the same directory","Preserve exec bits when extracting tarballs or copying binaries","Smoke-test with 'sd-daemon --version' after every install or update"],"tags":["cli","daemon","process","filesystem"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}