{"record":{"id":"9f4fb78d9b7c7b92","repo":"libnyanpasu/clash-nyanpasu","slug":"child-process-failed-err","errorCode":null,"errorMessage":"child process failed: {:?}, err: {}","messagePattern":"child process failed: (.+?), err: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"backend/tauri/src/utils/init/mod.rs","lineNumber":93,"sourceCode":"                    errs.push_str(unsafe { std::str::from_utf8_unchecked(&buf) });\n                }\n                Err(e) => {\n                    eprintln!(\"failed to read stderr: {e:?}\");\n                    let mut errs = errs_.lock();\n                    errs.push_str(&format!(\"failed to read stderr: {e:?}\\n\"));\n                    break;\n                }\n            }\n        }\n    });\n    let result = child.wait();\n    let _l = guard.write(); // Just for waiting the thread read all the output\n    let err = errs.lock();\n    result\n        .map_err(|e| anyhow!(\"Failed to wait for child: {:?}, errs: {}\", e, err))\n        .and_then(|status| {\n            if !status.success() {\n                Err(anyhow!(\"child process failed: {:?}, err: {}\", status, err))\n            } else {\n                Ok(())\n            }\n        })\n}\n\n/// Initialize all the config files\n/// before tauri setup\npub fn init_config() -> Result<()> {\n    // Check if old config dir exist and new config dir is not exist\n    // let mut old_app_dir: Option<PathBuf> = None;\n    // let mut app_dir: Option<PathBuf> = None;\n    // crate::dialog_err!(dirs::old_app_home_dir().map(|_old_app_dir| {\n    //     old_app_dir = Some(_old_app_dir);\n    // }));\n\n    // crate::dialog_err!(dirs::app_home_dir().map(|_app_dir| {\n    //     app_dir = Some(_app_dir);","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/utils/init/mod.rs#L75-L111","documentation":"run_pending_migrations runs a child process (migration sidecar) and waits for it. If the child exits with a non-zero status code, this anyhow error is raised wrapping the exit status and any collected stderr/stdout error strings from the child. It signals that a migration step did not complete successfully.","triggerScenarios":"Calling run_pending_migrations when the spawned child process exits with status.success() == false, e.g. the migration binary crashes or returns a failure exit code.","commonSituations":"Corrupt or incompatible app data directory blocking migrations; a missing/broken sidecar binary; migration script bug; insufficient permissions on the data directory; disk full.","solutions":["Read the captured child output (the `errs` content) in the error message to find the migration's own failure reason","Verify the migration sidecar binary exists and is executable (re-run pnpm prepare:check or reinstall)","Check permissions and free disk space on the app data directory","Fix or roll back the failing migration; if caused by a code change, run the migration binary manually to reproduce","Retry startup once the underlying cause is fixed"],"exampleFix":"// before: opaque failure\nErr(anyhow!(\"child process failed: {:?}, err: {}\", status, err))\n// after: also surface captured child output\nlet out = out_log.lock().join(\"\\n\");\nErr(anyhow!(\"child process failed: {:?}, err: {}, output: {}\", status, err, out))","handlingStrategy":"try-catch","validationCode":"let status = cmd.status()?;\nif !status.success() { bail!(\"migration sidecar unavailable (exit {})\", status); }","typeGuard":null,"tryCatchPattern":"match run_pending_migrations().await {\n    Ok(()) => {},\n    Err(e) => {\n        log::error!(\"migrations failed: {e:#}\");\n        // block startup or show recovery UI\n    }\n}","preventionTips":["Keep the migration sidecar in sync with the app version (prepare:check)","Capture and include child stdout/stderr in error messages","Test migrations against a copy of a real user data directory","Check disk space and permissions before spawning"],"tags":["process","migration","sidecar","exit-status"],"backgroundTag":"command-not-found","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}