libnyanpasu/clash-nyanpasu · error · anyhow::Error
failed to get core version
Error message
failed to get core version
What it means
resolve_core_version spawns the selected clash core sidecar binary with -v/-V and captures its output. If the process exits with a non-zero status, the version cannot be trusted, so this error is raised. It indicates the core binary is present (the command ran) but reported failure.
Source
Thrown at backend/tauri/src/utils/resolve.rs:795
};
app_handle.get_webview_window(window.label()).is_some()
}
/// resolve core version
// TODO: use enum instead
pub async fn resolve_core_version(app_handle: &AppHandle, core_type: &ClashCore) -> Result<String> {
let shell = app_handle.shell();
let core = core_type.clone().to_string();
log::debug!(target: "app", "check config in `{core}`");
let cmd = match core_type {
ClashCore::ClashPremium | ClashCore::Mihomo | ClashCore::MihomoAlpha | ClashCore::Meow => {
shell.sidecar(core)?.args(["-v"])
}
ClashCore::ClashRs | ClashCore::ClashRsAlpha => shell.sidecar(core)?.args(["-V"]),
};
let out = cmd.output().await?;
if !out.status.success() {
return Err(anyhow::anyhow!("failed to get core version"));
}
let out = String::from_utf8_lossy(&out.stdout);
log::trace!(target: "app", "get core version: {out:?}");
let out = out.trim().split(' ').collect::<Vec<&str>>();
for item in out {
log::debug!(target: "app", "check item: {item}");
if item.starts_with('v')
|| item.starts_with('n')
|| item.starts_with("alpha")
|| Version::parse(item).is_ok()
{
match core_type {
ClashCore::ClashRs => return Ok(format!("v{}", item)),
_ => return Ok(item.to_string()),
}
}
}
Err(anyhow::anyhow!("failed to get core version"))View on GitHub (pinned to f7dbce2997)
Solutions
- Log/print out.stderr to see the core's own failure message
- Run the core binary manually with -v (or -V for clash-rs) to reproduce and read the error
- Re-download or reinstall the core sidecar (pnpm prepare:check) to fix a corrupt/mismatched binary
- If a newer core dropped the -v flag, update the flag mapping in the match on ClashCore
Example fix
// before
if !out.status.success() {
return Err(anyhow::anyhow!("failed to get core version"));
}
// after: include stderr for diagnosis
if !out.status.success() {
return Err(anyhow::anyhow!(
"failed to get core version (status {:?}): {}",
out.status,
String::from_utf8_lossy(&out.stderr)
));
} Defensive patterns
Strategy: try-catch
Validate before calling
let ok = tokio::process::Command::new(core_path)
.arg("-v")
.output().await
.map(|o| o.status.success())
.unwrap_or(false);
if !ok { log::warn!("core binary cannot report version"); } Try / catch
match resolve_core_version(core).await {
Ok(v) => log::info!("core version: {v}"),
Err(e) => {
log::error!("core version check failed: {e:#}");
// fall back to assumed version or prompt reinstall
}
} Prevention
- Re-download sidecars after core version upgrades (prepare:check)
- Run the core binary manually with -v/-V after updates to verify output
- Check platform/arch compatibility of the sidecar build
- Capture stderr and include it in the error for faster diagnosis
When it happens
Trigger: cmd.output() succeeded but out.status.success() is false — the core binary rejects the -v flag, fails to initialize, or crashes at startup.
Common situations: Core version changed and no longer supports -v/-V; broken/incompatible build of mihomo or clash-rs; missing dynamic libraries or runtime deps causing early exit; sidecar mismatched with the platform.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- child process failed: {:?}, err: {}
- {} not found
- {operation} failed with status {status}
- {stderr}
- failed to copy core: {status}
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/e44504f4ac36103b.
Report an issue: GitHub.