{"record":{"id":"e66c0a75b63156f5","repo":"wasmerio/wasmer","slug":"journal-restore-error-failed-to-rename-path-old","errorCode":null,"errorMessage":"journal restore error: failed to rename path (old_fd={old_fd}, old_path={old_path}, new_fd={new_fd}, new_path={new_path}) - {ret}","messagePattern":"journal restore error: failed to rename path \\(old_fd=(.+?), old_path=(.+?), new_fd=(.+?), new_path=(.+?)\\) - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/wasix/src/journal/effector/syscalls/path_rename.rs","lineNumber":43,"sourceCode":"        ctx: &mut FunctionEnvMut<'_, WasiEnv>,\n        old_fd: Fd,\n        old_path: &str,\n        new_fd: Fd,\n        new_path: &str,\n    ) -> anyhow::Result<()> {\n        // see `VIRTUAL_ROOT_FD` for details as to why this exists\n        if old_fd == VIRTUAL_ROOT_FD && new_fd == VIRTUAL_ROOT_FD {\n            let state = ctx.data().state.clone();\n            let old_path = old_path.to_string();\n            let new_path = new_path.to_string();\n            __asyncify_light(ctx.data(), None, async move {\n                state.fs_rename(old_path, new_path).await\n            })??;\n        } else {\n            let ret =\n                crate::syscalls::path_rename_internal(ctx, old_fd, old_path, new_fd, new_path)?;\n            if ret != Errno::Success {\n                bail!(\n                    \"journal restore error: failed to rename path (old_fd={old_fd}, old_path={old_path}, new_fd={new_fd}, new_path={new_path}) - {ret}\"\n                );\n            }\n        }\n        Ok(())\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":51,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/wasix/src/journal/effector/syscalls/path_rename.rs#L25-L51","documentation":"apply_path_rename replays a PathRename entry; in the non-async/stateless path, path_rename_internal must return Errno::Success, otherwise this bail fires with the old/new fds and paths. The rename from the snapshot could not be reproduced, leaving the restored filesystem inconsistent.","triggerScenarios":"Journal restore replaying PathRename when the source path doesn't exist (Noent), source or base fds are invalid, destination directory is missing, or capability rights prevent the rename.","commonSituations":"Restoring onto a filesystem where the old_path was already renamed or removed; mismatched mounts between capture and restore hosts; missing write rights on the destination directory preopen.","solutions":["Align the filesystem contents of the restore environment with the snapshot (ensure old_path exists and new_path's parent exists).","Grant write rights on both source and destination preopen directories.","Ensure journal entries are applied in the original order.","Use the same runtime version for snapshot creation and restore."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight: old_path must exist and new_path's parent must exist\nfor op in journal.rename_entries() {\n    let from = env.resolve_preopen_path(op.old_fd, &op.old_path)\n        .ok_or_else(|| anyhow::anyhow!(\"bad old_fd {} for restore\", op.old_fd))?;\n    if !std::path::Path::new(&from).exists() {\n        return Err(anyhow::anyhow!(\"rename source '{}' missing at restore\", from));\n    }\n}","typeGuard":"fn rename_source_ok(p: &std::path::Path) -> bool {\n    std::fs::symlink_metadata(p).is_ok()\n}","tryCatchPattern":"match restore_from_journal(&env, &journal) {\n    Err(e) if e.to_string().contains(\"failed to rename path\") => {\n        eprintln!(\"rename replay failed: {e}; syncing fs state and retrying\");\n        sync_fs_and_retry()?;\n    }\n    other => other?,\n}","preventionTips":["Ensure restore filesystem state matches snapshot (source paths intact).","Grant write rights to both source and destination preopens.","Keep runtime versions identical between capture and restore."],"tags":["wasix","journal","path-rename","filesystem","snapshot-restore"],"backgroundTag":"journal-restore-failed","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}