{"record":{"id":"e43c5122c936d343","repo":"spacedriveapp/spacedrive","slug":"daemon-binary-not-found-at-ensure-both-sd-cli","errorCode":null,"errorMessage":"Daemon binary not found at {}. Ensure both 'sd-cli' and 'sd-daemon' are in the same directory.","messagePattern":"Daemon binary not found at (.+?)\\. Ensure both 'sd-cli' and 'sd-daemon' are in the same directory\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/daemon/mod.rs","lineNumber":51,"sourceCode":"\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\"))?\n\t\t.join(\"sd-daemon\");\n\n\tif !daemon_path.exists() {\n\t\treturn Err(anyhow::anyhow!(\n\t\t\t\"Daemon binary not found at {}. Ensure both 'sd-cli' and 'sd-daemon' are in the same directory.\",\n\t\t\tdaemon_path.display()\n\t\t));\n\t}\n\n\t// Determine log paths\n\tlet log_dir = data_dir.join(\"logs\");\n\tfs::create_dir_all(&log_dir)?;\n\tlet stdout_log = log_dir.join(\"daemon.out.log\");\n\tlet stderr_log = log_dir.join(\"daemon.err.log\");\n\n\t// Build program arguments\n\tlet mut program_args = vec![\n\t\tdaemon_path.to_string_lossy().to_string(),\n\t\t\"--data-dir\".to_string(),\n\t\tdata_dir.to_string_lossy().to_string(),\n\t];\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/daemon/mod.rs#L33-L69","documentation":"When `sd-cli daemon install` runs on macOS, it writes a LaunchAgent plist whose ProgramArguments must point at an `sd-daemon` binary. The path is derived from `std::env::current_exe().parent().join(\"sd-daemon\")`, i.e. the daemon is expected to sit in the same directory as the running `sd-cli`. This error means that sibling path does not exist, so the plist cannot be generated.","triggerScenarios":"Running `sd-cli daemon install` after building only the CLI (`cargo build --bin sd-cli`), running sd-cli copied out of a bundle without sd-daemon, or mixing target profiles (sd-cli taken from target/release while sd-daemon was only built into target/debug).","commonSituations":"Partial installs where a script copies one binary; developers using `cargo run --bin sd-cli -- daemon install` in a workspace where sd-daemon was never compiled; packaging pipelines that ship sd-cli and sd-daemon to different directories.","solutions":["Build both binaries so they land in the same target directory: `cargo build --bin sd-cli --bin sd-daemon` (or plain `cargo build`), then rerun `sd-cli daemon install`.","If sd-cli is installed elsewhere, copy or symlink the daemon next to it: `cp target/release/sd-daemon \"$(dirname \"$(which sd-cli)\")/\"`.","Verify the sibling layout before retrying: `ls -l \"$(dirname \"$(which sd-cli)\")\" | grep sd-daemon`."],"exampleFix":"# before: only the CLI was built\ncargo build --bin sd-cli\nsd-cli daemon install  # -> Daemon binary not found at ...\n\n# after: both binaries share target/release\ncargo build --bin sd-cli --bin sd-daemon\nsd-cli daemon install  # -> Created LaunchAgent: ~/Library/LaunchAgents/com.spacedrive.daemon.plist","handlingStrategy":"validation","validationCode":"fn daemon_sibling_exists() -> anyhow::Result<std::path::PathBuf> {\n    let exe = std::env::current_exe()?;\n    let dir = exe.parent().ok_or_else(|| anyhow::anyhow!(\"no exe parent\"))?;\n    let daemon = dir.join(\"sd-daemon\");\n    if daemon.is_file() { Ok(daemon) } else { anyhow::bail!(\"missing {} — build both binaries\", daemon.display()) }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = install_autostart().await {\n    if e.to_string().contains(\"Daemon binary not found\") {\n        eprintln!(\"build sd-daemon into the same dir as sd-cli, then retry\");\n    }\n    return Err(e);\n}","preventionTips":["Build the workspace with plain `cargo build` so all binaries share target/<profile>.","In packaging scripts, always install sd-cli and sd-daemon together into the same bin directory.","Run a preflight check `test -x \"$(dirname \"$(command -v sd-cli)\")/sd-daemon\"` before calling daemon install."],"tags":["macos","launchd","daemon","binary","install"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}