openai/codex · error · OAuthStoreLockFailure

failed to resolve CODEX_HOME for MCP OAuth

Error message

failed to resolve CODEX_HOME for MCP OAuth {store} aggregate-store lock

What it means

Raised when building the aggregate-store lock path for MCP OAuth credentials: the CODEX_HOME environment variable could not be resolved to a directory (unset or invalid), so no lock file path could be constructed and the store operation must fail rather than proceed unlocked.

Solutions

  1. Set the CODEX_HOME environment variable to a writable directory
  2. Fix permissions on the CODEX_HOME path so it can be resolved
  3. Ensure codex is launched with the environment intact (no stripped env)
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/rmcp-client/src/oauth/store_lock.rs:168 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/86a2b1ac6a5d8a7f. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/rmcp-client/src/oauth/store_lock.rs:168

                }
                Err(error) => {
                    return Err(OAuthStoreLockFailure::Lock {
                        store,
                        path,
                        source: io::Error::from(error),
                    });
                }
            }
        }
    }
}

/// Auto may fall back when the configured keyring backend is unavailable, but it must surface a
/// lock failure. Falling back while another process owns the aggregate-store lock could leave the
/// newer credential in File while a stale Secrets entry remains preferred.
#[derive(Debug, thiserror::Error)]
pub(super) enum OAuthStoreLockFailure {
    #[error("failed to resolve CODEX_HOME for MCP OAuth {store} aggregate-store lock")]
    CodexHome {
        store: OAuthStore,
        #[source]
        source: io::Error,
    },
    #[error("failed to create MCP OAuth {store} aggregate-store lock directory {}", path.display())]
    CreateDir {
        store: OAuthStore,
        path: PathBuf,
        #[source]
        source: io::Error,
    },
    #[error("failed to open MCP OAuth {store} aggregate-store lock {}", path.display())]
    Open {
        store: OAuthStore,
        path: PathBuf,
        #[source]
        source: io::Error,

View on GitHub (pinned to 339751715c)