openai/codex · error · std::io::Error

memory root cannot be a symbolic link

Error message

memory root cannot be a symbolic link: {}

What it means

ensure_layout created (or found) the memory root path but symlink_metadata shows it is a symbolic link. Since memory consolidation later runs git and file operations rooted there, a symlinked root is rejected with ErrorKind::InvalidInput to keep the layout well-defined.

Solutions

  1. Replace the symlinked memory root with a real directory
  2. Adjust CODEX_HOME so memories resolve to a non-symlink path
  3. Manually migrate the linked content into the real directory and remove the link
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/memories/write/src/lib.rs:139 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/5f21bc3f10c58b94. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/memories/write/src/lib.rs:139

    root.join(artifacts::ROLLOUT_SUMMARIES_SUBDIR)
}

pub fn memory_extensions_root(root: &Path) -> PathBuf {
    root.join(artifacts::EXTENSIONS_SUBDIR)
}

pub fn raw_memories_file(root: &Path) -> PathBuf {
    root.join(artifacts::RAW_MEMORIES_FILENAME)
}

pub async fn ensure_layout(root: &Path) -> std::io::Result<()> {
    tokio::fs::create_dir_all(root).await?;
    if tokio::fs::symlink_metadata(root)
        .await?
        .file_type()
        .is_symlink()
    {
        return Err(std::io::Error::new(
            std::io::ErrorKind::InvalidInput,
            format!("memory root cannot be a symbolic link: {}", root.display()),
        ));
    }

    workspace::remove_memory_symlinks(root).await?;
    tokio::fs::create_dir_all(rollout_summaries_dir(root)).await
}

View on GitHub (pinned to 339751715c)