Hmbown/CodeWhale · error
Cannot resolve current binary path
Error message
Cannot resolve current binary path: {e} What it means
Thrown by the `AddSelf` MCP command when `std::env::current_exe()` fails to resolve the path of the currently running binary. Since AddSelf registers this binary itself as an MCP server command, it cannot build the registration without a resolvable executable path and bails.
Solutions
- Re-run the command from a stable, installed binary (not a rebuilt cargo target path)
- If the binary was deleted after launch, reinstall or re-copy it, then retry
- As a fallback, register the server manually with an explicit absolute path to the binary
- Avoid running AddSelf from ephemeral build artifacts; install the CLI first
Example fix
// before
let exe_path = std::env::current_exe()
.map_err(|e| anyhow!("Cannot resolve current binary path: {e}"))?;
// after
let exe_path = std::env::current_exe()
.map_err(|e| anyhow!("Cannot resolve current binary path: {e}; install the binary to a stable location and retry"))?;
let exe_path = if !exe_path.exists() {
anyhow::bail!("Resolved binary {} no longer exists on disk", exe_path.display());
} else { exe_path }; Defensive patterns
Strategy: try-catch
Validate before calling
// Rust
let exe = std::env::current_exe()?;
if !exe.exists() {
bail!("running binary at {} no longer exists on disk; reinstall and retry", exe.display());
} Try / catch
// Rust
match add_self(&name, workspace) {
Err(e) if e.to_string().contains("Cannot resolve current binary path") => {
eprintln!("Binary path unresolvable (deleted/rebuilt?). Install a stable binary and retry, or register manually with an absolute path.");
std::process::exit(1);
}
other => other,
} Prevention
- Install the CLI to a stable location instead of registering a cargo target/ temp binary
- Avoid rebuilding while a session using that binary is live
- Manually register the MCP server with an explicit absolute path as a fallback
- On self-updating setups, re-run AddSelf after update
When it happens
Trigger: `std::env::current_exe()` returns Err — the executable was deleted or replaced after launch (common with self-updating/cargo-run temp binaries), /proc lookup failed, or the platform denied path resolution.
Common situations: Running from `cargo run` where the target binary was rebuilt/deleted mid-session; deleted binary on Linux (/proc/self/exe dangling); executing via a hardlink that was removed; unusual sandboxed or FUSE filesystems.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- already exists; pass --force to overwrite it
- Command failed with exit code
- Command timed out after
- dsh exited with status
- editor exited with
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/94cf18be5ecc8fbf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:10266
let mut pool = McpPool::from_config_path_with_workspace_and_plugins(
&config_path,
workspace,
std::sync::Arc::new(plugins.clone()),
)?;
let errors = pool.connect_all().await;
if errors.is_empty() {
println!("MCP config is valid. All enabled servers connected.");
return Ok(());
}
eprintln!("MCP validation failed:");
for (name, err) in errors {
eprintln!(" - {name}: {err:#}");
}
bail!("one or more MCP servers failed validation");
}
McpCommand::AddSelf { name, workspace } => {
let exe_path = std::env::current_exe()
.map_err(|e| anyhow!("Cannot resolve current binary path: {e}"))?;
let exe_str = exe_path.to_string_lossy().to_string();
let mut args = Vec::with_capacity(if workspace.is_some() { 4 } else { 2 });
if let Some(ref ws) = workspace {
args.push("--workspace".to_string());
args.push(ws.clone());
}
args.push("serve".to_string());
args.push("--mcp".to_string());
crate::mcp::mutate_config(&config_path, None, |cfg| {
if cfg.servers.contains_key(&name) {
bail!(
"MCP server '{name}' already exists in {}. Use `codewhale mcp remove {name}` first, or choose a different --name.",
config_path.display()
);
}
cfg.servers.insert(View on GitHub (pinned to 73e0f67d83)