BigPizzaV3/CodexPlusPlus · critical · anyhow::Error

同步当前供应商失败: ;回滚 live 配置也失败:

Error message

同步当前供应商失败:{error};回滚 live 配置也失败:{restore_error}

What it means

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.

Solutions

  1. 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).
  2. Manually inspect and repair the live config.toml / restore from backup, since the automatic rollback failed.
  3. Check filesystem permissions and free space on the home directory used for Codex config.
  4. Disable relay profiles (relay_profiles_enabled=false) to bypass the sync path if you just need to launch.

Example fix

// before: command fails because profile incomplete and rollback also failed
// after: validate settings before launching
if settings.relay_profiles_enabled {
    if let Some(active) = settings.active_aggregate_relay_profile() {
        if active.is_none() {
            return Err(anyhow::anyhow!("fix aggregate profile before launch"));
        }
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

if !settings.relay_profiles_enabled {
    return Err(anyhow::anyhow!("relay profiles disabled; cannot sync"));
}
// ensure config dir is writable
let probe = home.join("config.toml");
let meta = std::fs::metadata(&probe)?;
if meta.permissions().readonly() {
    return Err(anyhow::anyhow!("config.toml is read-only; sync would fail and rollback may too"));
}

Type guard

fn aggregate_profile_complete(settings: &BackendSettings) -> bool {
    settings.active_aggregate_relay_profile().is_some()
}

Try / catch

match sync_active_relay_to_home(settings, home) {
    Err(e) => {
        eprintln!("sync failed: {e}; live config may be inconsistent — restore from backup manually");
        Err(e)
    }
    ok => ok,
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/2c2382104e87d7cd. Report an issue: GitHub.

Appendix: source

Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:945

    wait_native()?;
    stop_launcher()?;
    Ok(())
}

fn restart_codex_plus_after_stop<F>(
    request: &LaunchRequest,
    home: &Path,
    settings: Option<&BackendSettings>,
    spawn: F,
) -> anyhow::Result<()>
where
    F: FnOnce(&LaunchRequest) -> anyhow::Result<()>,
{
    let snapshot = if let Some(settings) = settings {
        let snapshot = RelayLiveSnapshot::capture(home)?;
        if let Err(error) = sync_active_relay_to_home(settings, home) {
            if let Err(restore_error) = snapshot.restore(home) {
                anyhow::bail!("同步当前供应商失败:{error};回滚 live 配置也失败:{restore_error}");
            }
            return Err(error);
        }
        Some(snapshot)
    } else {
        None
    };

    if let Err(error) = spawn(request) {
        if let Some(snapshot) = snapshot {
            if let Err(restore_error) = snapshot.restore(home) {
                anyhow::bail!("启动静默入口失败:{error};回滚 live 配置也失败:{restore_error}");
            }
        }
        return Err(error);
    }
    Ok(())
}

View on GitHub (pinned to b1ed92e5e4)