spacedriveapp/spacedrive · error · anyhow::Error

Failed to start daemon: {}

Error message

Failed to start daemon: {}

What it means

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.

Source

Thrown at apps/cli/src/main.rs:307

			// Set working directory to current directory
			command.current_dir(std::env::current_dir()?);

			if foreground {
				// Foreground mode: inherit stdout/stderr so logs are visible
				println!("Starting daemon in foreground mode...");
				println!("Press Ctrl+C to stop the daemon");
				println!("═══════════════════════════════════════════════════════");

				match command.status() {
					Ok(status) => {
						if status.success() {
							println!("Daemon exited successfully");
						} else {
							return Err(anyhow::anyhow!("Daemon exited with error: {}", status));
						}
					}
					Err(e) => {
						return Err(anyhow::anyhow!("Failed to start daemon: {}", e));
					}
				}
			} else {
				// Background mode: redirect stdout/stderr to null
				command.stdout(std::process::Stdio::null());
				command.stderr(std::process::Stdio::null());

				match command.spawn() {
					Ok(child) => {
						println!("Daemon started (PID: {})", child.id());

						// Wait a moment for daemon to start up
						tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;

						// Verify daemon is responding
						match client
							.send_raw_request(&sd_core::infra::daemon::types::DaemonRequest::Ping)
							.await

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Confirm sd-daemon exists beside the sd binary: ls $(dirname $(which sd))
  2. chmod +x sd-daemon and retry
  3. Reinstall a release build matching your platform, or cargo build both binaries from source
Defensive patterns

Strategy: try-catch

Validate before calling

#!/usr/bin/env bash
bin_dir=$(dirname "$(command -v sd)")
[ -x "$bin_dir/sd-daemon" ] || { echo "sd-daemon missing or not executable in $bin_dir" >&2; exit 2; }
sd start --foreground

Type guard

fn daemon_executable(bin_dir: &std::path::Path) -> Option<std::path::PathBuf> {
    let p = bin_dir.join("sd-daemon");
    p.is_file().then(|| p).filter(|p| p.metadata().map(|m| m.permissions().mode() & 0o111 != 0).unwrap_or(false))
}

Try / catch

if let Err(e) = command.status() {
    let hint = match e.kind() {
        std::io::ErrorKind::NotFound => "sd-daemon not found next to the sd binary",
        std::io::ErrorKind::PermissionDenied => "run chmod +x sd-daemon",
        _ => "check architecture/exec format of sd-daemon",
    };
    anyhow::bail!("Failed to start daemon: {} ({})", e, hint);
}

Prevention

When it happens

Trigger: Only the sd CLI binary was installed; sd-daemon lost its executable bit after a copy; a binary built for a different target triple.

Common situations: Partial manual installs; extracting release tarballs without preserving modes; mixing builds across machines.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/f145d61a30decad3. Report an issue: GitHub.