{"record":{"id":"00fb1192278b5ec9","repo":"spacedriveapp/spacedrive","slug":"could-not-determine-binary-directory-00fb11","errorCode":null,"errorMessage":"Could not determine binary directory","messagePattern":"Could not determine binary directory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/update/mod.rs","lineNumber":91,"sourceCode":"\tlet daemon_asset = latest_release\n\t\t.assets\n\t\t.iter()\n\t\t.find(|a| a.name.contains(&platform) && a.name.contains(\"sd-daemon\"))\n\t\t.ok_or_else(|| {\n\t\t\tanyhow::anyhow!(\"Could not find sd-daemon binary for platform: {}\", platform)\n\t\t})?;\n\n\tprintln!(\"Downloading updates...\");\n\n\t// Download binaries\n\tlet sd_data = download_file(&sd_asset.browser_download_url, sd_asset.size).await?;\n\tlet daemon_data = download_file(&daemon_asset.browser_download_url, daemon_asset.size).await?;\n\n\t// Get current binary paths\n\tlet current_exe = std::env::current_exe()?;\n\tlet bin_dir = current_exe\n\t\t.parent()\n\t\t.ok_or_else(|| anyhow::anyhow!(\"Could not determine binary directory\"))?;\n\n\tlet sd_path = bin_dir.join(\"sd\");\n\tlet daemon_path = bin_dir.join(\"sd-daemon\");\n\n\tprintln!();\n\tprintln!(\"Installing updates...\");\n\n\t// Check if daemon is running\n\tlet daemon_was_running = check_daemon_running(&data_dir).await;\n\tif daemon_was_running {\n\t\tprintln!(\"Stopping daemon...\");\n\t\tstop_daemon(&data_dir).await?;\n\t}\n\n\t// Perform atomic replacement\n\treplace_binary(&sd_path, &sd_data)?;\n\treplace_binary(&daemon_path, &daemon_data)?;\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/update/mod.rs#L73-L109","documentation":"The updater takes std::env::current_exe() and asks for its parent directory to decide where to install 'sd' and 'sd-daemon'. parent() returned None, meaning the executable path is degenerate (empty or a root-like path). This is a defensive guard for a condition that is nearly impossible on healthy systems.","triggerScenarios":"Executing the CLI in a sandbox/namespace where /proc/self/exe resolves to something without a parent component; a broken exec chain returning an empty argv[0]-derived path.","commonSituations":"Exotic containers or chroots; essentially never seen in normal desktop/server use.","solutions":["Run the CLI from a normal absolute install path (e.g. ~/.local/bin/sd) and retry","Reinstall both binaries with well-formed paths","Patch the updater to accept an explicit --bin-dir override if you hit this in automation"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"fn bin_dir() -> anyhow::Result<std::path::PathBuf> {\n    std::env::current_exe()\n        .ok()\n        .and_then(|p| p.parent().map(|d| d.to_path_buf()))\n        .or_else(|| std::env::var(\"SD_BIN_DIR\").ok().map(std::path::PathBuf::from))\n        .ok_or_else(|| anyhow::anyhow!(\"Could not determine binary directory; set SD_BIN_DIR\"))\n}","typeGuard":null,"tryCatchPattern":"let bin_dir = match current_exe.parent() {\n    Some(d) => d.to_path_buf(),\n    None => std::path::PathBuf::from(\"/usr/local/bin\"), // documented fallback\n};","preventionTips":["Invoke the CLI via an absolute path from a real directory, never from a degenerate path","Offer an explicit --bin-dir flag in the updater so install location never depends on argv heuristics","Treat hitting this error as an environment smell worth investigating, not a code bug"],"tags":["cli","update","filesystem","edge-case"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}