{"record":{"id":"2c2382104e87d7cd","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-live-restore-error","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":945,"sourceCode":"    wait_native()?;\n    stop_launcher()?;\n    Ok(())\n}\n\nfn restart_codex_plus_after_stop<F>(\n    request: &LaunchRequest,\n    home: &Path,\n    settings: Option<&BackendSettings>,\n    spawn: F,\n) -> anyhow::Result<()>\nwhere\n    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}","sourceCodeStart":927,"sourceCodeEnd":963,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/apps/codex-plus-manager/src-tauri/src/commands.rs#L927-L963","documentation":"Thrown by the launch command wrapper (commands.rs) when syncing the currently active relay profile into the live config.toml fails, AND the subsequent rollback via the captured RelayLiveSnapshot also fails. Both the original sync error and the restore error are embedded so the developer can see the root cause plus the fact that the live config may now be in a partially modified state.","triggerScenarios":"Calling launch_start (or similar command that takes settings and spawns via F: FnOnce(&LaunchRequest)) with relay_profiles_enabled and a home dir where sync_active_relay_to_home fails (e.g. config.toml unreadable/unwritable, incomplete profile), and then RelayLiveSnapshot::restore also fails (e.g. snapshot file/backup cannot be written back, permission or IO error).","commonSituations":"Read-only or locked config.toml (editor/another process holding it); corrupted settings leaving the aggregate profile incomplete; disk-full or permission errors preventing both write and rollback.","solutions":["Read the embedded {error} first — it is the root cause of the sync failure; fix that (e.g. repair the relay profile or config.toml permissions).","Manually inspect and repair the live config.toml / restore from backup, since the automatic rollback failed.","Check filesystem permissions and free space on the home directory used for Codex config.","Disable relay profiles (relay_profiles_enabled=false) to bypass the sync path if you just need to launch."],"exampleFix":"// before: command fails because profile incomplete and rollback also failed\n// after: validate settings before launching\nif settings.relay_profiles_enabled {\n    if let Some(active) = settings.active_aggregate_relay_profile() {\n        if active.is_none() {\n            return Err(anyhow::anyhow!(\"fix aggregate profile before launch\"));\n        }\n    }\n}","handlingStrategy":"try-catch","validationCode":"if !settings.relay_profiles_enabled {\n    return Err(anyhow::anyhow!(\"relay profiles disabled; cannot sync\"));\n}\n// ensure config dir is writable\nlet probe = home.join(\"config.toml\");\nlet meta = std::fs::metadata(&probe)?;\nif meta.permissions().readonly() {\n    return Err(anyhow::anyhow!(\"config.toml is read-only; sync would fail and rollback may too\"));\n}","typeGuard":"fn aggregate_profile_complete(settings: &BackendSettings) -> bool {\n    settings.active_aggregate_relay_profile().is_some()\n}","tryCatchPattern":"match sync_active_relay_to_home(settings, home) {\n    Err(e) => {\n        eprintln!(\"sync failed: {e}; live config may be inconsistent — restore from backup manually\");\n        Err(e)\n    }\n    ok => ok,\n}","preventionTips":["Validate relay profile completeness before launching.","Keep a manual backup of config.toml before programmatic syncs.","Ensure no other process holds config.toml open with a write lock.","Monitor disk space/permissions on the Codex home directory."],"tags":["config-sync","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"}