BigPizzaV3/CodexPlusPlus · error
找不到原生会话文件
Error message
找不到原生会话文件
What it means
export_rollout looks up the native codex rollout file for a given session id under the codex home via find_rollout. If no matching file exists on disk it raises this error. It means the share/export target session is not present in the local codex sessions directory.
Solutions
- Verify the session id exists under ~/.codex/sessions (or the configured CODEX_HOME) and matches a rollout file.
- Point the export call at the correct home directory containing the session.
- Re-check the session id for typos; list available sessions and pick the right one.
- Restore the rollout file from backup or re-run the session if the file was deleted.
Example fix
// before
export_rollout(&wrong_home, "3f2a1b8c-...")?;
// after
let home = dirs::home_dir().unwrap().join(".codex");
export_rollout(&home, "3f2a1b8c-9d4e-4f01-8a2b-7c6d5e4f3a2b")?; Defensive patterns
Strategy: try-catch
Validate before calling
const fs = require('fs');
const path = require('path');
function rolloutExists(home, sessionId) {
const dir = path.join(home, 'sessions');
return findRecursive(dir, f => f.includes(sessionId)).length > 0;
} Try / catch
try {
await api.exportRollout(sessionId);
} catch (e) {
if (String(e).includes('找不到原生会话文件')) {
alert('本地未找到该会话,请确认会话在本机创建或已恢复备份');
} else { throw e; }
} Prevention
- Only share sessions created on the local machine.
- Keep CODEX_HOME consistent across app restarts.
- Avoid cleanup scripts that delete sessions/*.jsonl.
- Validate the session id against the local session list before exporting.
When it happens
Trigger: Calling export_rollout with a session id that was never created locally; sessions directory moved or cleaned; wrong codex home directory configured; mistyped/foreign session id.
Common situations: Trying to share a session from another machine; home directory changed after a codex upgrade; session files deleted by cleanup scripts; using an id from an imported share that was never imported locally.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/b03f7dbe03511fca.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:186
.unwrap_or("导入的会话");
import_rollout(
home,
&json!({
"kind": "codex-rollout",
"session_id": session_id,
"content": content,
"title": title,
}),
)
}
pub fn export_rollout(home: &Path, session_id: &str) -> anyhow::Result<Value> {
let session_id = session_id.trim();
if session_id.is_empty() {
bail!("会话 ID 为空");
}
let path =
find_rollout(home, session_id).ok_or_else(|| anyhow::anyhow!("找不到原生会话文件"))?;
let bytes = fs::read(&path).with_context(|| format!("读取会话文件失败:{}", path.display()))?;
if bytes.len() > MAX_ROLLOUT_BYTES {
bail!("会话文件超过分享大小限制");
}
let content = String::from_utf8(bytes).context("会话文件不是有效的 UTF-8")?;
Ok(json!({
"status": "ok",
"kind": "codex-rollout",
"session_id": session_id,
"content": content,
"filename": path.file_name().and_then(|value| value.to_str()).unwrap_or("rollout.jsonl"),
}))
}
pub fn import_rollout(home: &Path, payload: &Value) -> anyhow::Result<Value> {
if payload.get("kind").and_then(Value::as_str) != Some("codex-rollout") {
bail!("不支持的会话文件格式");
}View on GitHub (pinned to b1ed92e5e4)