openai/codex · error · anyhow::Error
failed to persist secrets key in keyring
Error message
failed to persist secrets key in keyring
What it means
A freshly generated secrets passphrase could not be stored in the OS keyring, so future loads of the encrypted secrets file would fail; persistence is aborted.
Solutions
- Check keyring availability/permissions and retry the save
- Fall back to prompting the user or an alternative storage backend
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at codex-rs/secrets/src/local.rs:253 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/64a2804368df677a.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/secrets/src/local.rs:253
}
fn load_or_create_passphrase(&self) -> Result<SecretString> {
let account = compute_keyring_account(&self.codex_home);
let loaded = self
.keyring_store
.load(keyring_service(), &account)
.map_err(|err| anyhow::anyhow!(err.message()))
.with_context(|| format!("failed to load secrets key from keyring for {account}"))?;
match loaded {
Some(existing) => Ok(SecretString::from(existing)),
None => {
// Generate a high-entropy key and persist it in the OS keyring.
// This keeps secrets out of plaintext config while remaining
// fully local/offline for the MVP.
let generated = generate_passphrase()?;
self.keyring_store
.save(keyring_service(), &account, generated.expose_secret())
.map_err(|err| anyhow::anyhow!(err.message()))
.context("failed to persist secrets key in keyring")?;
Ok(generated)
}
}
}
}
impl SecretsBackend for LocalSecretsBackend {
fn set(&self, scope: &SecretScope, name: &SecretName, value: &str) -> Result<()> {
LocalSecretsBackend::set(self, scope, name, value)
}
fn get(&self, scope: &SecretScope, name: &SecretName) -> Result<Option<String>> {
LocalSecretsBackend::get(self, scope, name)
}
fn delete(&self, scope: &SecretScope, name: &SecretName) -> Result<bool> {
LocalSecretsBackend::delete(self, scope, name)View on GitHub (pinned to 339751715c)