{"record":{"id":"041d2f710a607e1e","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-live-restore-error-041d2f","errorCode":null,"errorMessage":"启动静默入口失败：{error}；回滚 live 配置也失败：{restore_error}","messagePattern":"启动静默入口失败：(.+?)；回滚 live 配置也失败：(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"apps/codex-plus-manager/src-tauri/src/commands.rs","lineNumber":957,"sourceCode":"    F: FnOnce(&LaunchRequest) -> anyhow::Result<()>,\n{\n    let snapshot = if let Some(settings) = settings {\n        let snapshot = RelayLiveSnapshot::capture(home)?;\n        if let Err(error) = sync_active_relay_to_home(settings, home) {\n            if let Err(restore_error) = snapshot.restore(home) {\n                anyhow::bail!(\"同步当前供应商失败：{error}；回滚 live 配置也失败：{restore_error}\");\n            }\n            return Err(error);\n        }\n        Some(snapshot)\n    } else {\n        None\n    };\n\n    if let Err(error) = spawn(request) {\n        if let Some(snapshot) = snapshot {\n            if let Err(restore_error) = snapshot.restore(home) {\n                anyhow::bail!(\"启动静默入口失败：{error}；回滚 live 配置也失败：{restore_error}\");\n            }\n        }\n        return Err(error);\n    }\n    Ok(())\n}\n\n#[derive(Debug)]\nstruct RelayLiveSnapshot {\n    config: Option<Vec<u8>>,\n    auth: Option<Vec<u8>>,\n}\n\nimpl RelayLiveSnapshot {\n    fn capture(home: &Path) -> anyhow::Result<Self> {\n        Ok(Self {\n            config: read_optional_file_bytes(&home.join(\"config.toml\"))?,\n            auth: read_optional_file_bytes(&home.join(\"auth.json\"))?,","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/apps/codex-plus-manager/src-tauri/src/commands.rs#L939-L975","documentation":"Thrown when the spawned launch process (the silent launcher entry) fails via spawn(request), and restoring the previously captured RelayLiveSnapshot of the live config also fails during cleanup. The message carries both the original launch error and the restore error, indicating the live config may be left in the pre-launch (but not guaranteed-original) state.","triggerScenarios":"Calling a launch command (commands.rs) after a successful sync_active_relay_to_home, where spawn(request) returns Err (launcher binary missing, port conflict, exec failure) and snapshot.restore(home) then errors (config.toml write failure, permissions, IO).","commonSituations":"Launcher executable not found or not built; antivirus/permissions blocking process spawn; config.toml locked by another process so restore cannot write back.","solutions":["Read the embedded {error} — fix the underlying launch failure first (e.g. ensure the launcher binary exists and is executable).","Manually verify/restore config.toml since automatic restore failed; check for locks on the file.","Check filesystem permissions and disk space in the Codex home directory.","Retry the launch after closing other Codex/manager processes that may hold config.toml."],"exampleFix":"// before: spawn fails and rollback fails, config possibly inconsistent\n// after: pre-check launcher availability before sync\nif !launcher_binary_exists() {\n    return Err(anyhow::anyhow!(\"launcher binary missing; skipping live sync\"));\n}\nlet snapshot = RelayLiveSnapshot::capture(home)?;","handlingStrategy":"try-catch","validationCode":"// pre-check before sync+spawn\nif !PathBuf::from(launcher_path).exists() {\n    return Err(anyhow::anyhow!(\"launcher binary missing\"));\n}\nlet snapshot = RelayLiveSnapshot::capture(home)?;","typeGuard":"fn snapshot_restorable(snapshot: &Option<RelayLiveSnapshot>, home: &Path) -> bool {\n    snapshot.as_ref().map(|s| s.can_restore(home)).unwrap_or(true)\n}","tryCatchPattern":"if let Err(error) = spawn(request) {\n    if let Err(restore_error) = snapshot.map(|s| s.restore(home)) {\n        eprintln!(\"launch failed: {error}; restore also failed: {restore_error:?} — repair config.toml manually\");\n    }\n    return Err(error);\n}","preventionTips":["Verify the launcher binary exists and is executable before spawning.","Close other Codex/manager instances that may lock config.toml.","Keep a periodic backup of config.toml to recover from failed rollbacks.","Test spawn in a dry-run mode before syncing live config."],"tags":["process-spawn","rollback-failed","relay-profile","tauri-command","io"],"backgroundTag":"file-write-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}