{"record":{"id":"16495828d3120046","repo":"wasmerio/wasmer","slug":"journal-restore-error-failed-to-open-descriptor","errorCode":null,"errorMessage":"journal restore error: failed to open descriptor (fd={fd}, path={path}) - {err}","messagePattern":"journal restore error: failed to open descriptor \\(fd=(.+?), path=(.+?)\\) - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/wasix/src/journal/effector/syscalls/path_open.rs","lineNumber":61,"sourceCode":"        fs_flags: Fdflags,\n        fd_flags: Fdflagsext,\n    ) -> anyhow::Result<()> {\n        let res = crate::syscalls::path_open_internal(\n            ctx.data(),\n            dirfd,\n            dirflags,\n            path,\n            o_flags,\n            fs_rights_base,\n            fs_rights_inheriting,\n            fs_flags,\n            fd_flags,\n            Some(fd),\n        );\n        match res? {\n            Ok(fd) => fd,\n            Err(err) => {\n                bail!(\n                    \"journal restore error: failed to open descriptor (fd={fd}, path={path}) - {err}\"\n                );\n            }\n        };\n        Ok(())\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":69,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/wasix/src/journal/effector/syscalls/path_open.rs#L43-L69","documentation":"apply_path_open replays a PathOpen journal entry by re-opening the recorded path at the expected fd; if the internal open returns an error, this bail fires with the fd and path. The restored process would otherwise be missing a file descriptor that existed in the snapshot.","triggerScenarios":"Journal restore applying PathOpen when path_open_internal fails: file missing on the restored filesystem, wrong base dir fd, permission/capability (Notcapable) issues, or the preopen for the path is absent.","commonSituations":"Snapshot taken on a machine/container whose mounted volumes or working directory contents differ from the restore target; missing read/write rights on the preopened directory; relative paths no longer resolvable after restore.","solutions":["Ensure the file at `path` exists in the restored environment (restore the volume/workdir contents).","Verify the base directory preopen and its rights (read/write) match the snapshot environment.","Check path casing/symlinks differences between capture and restore hosts.","Retake the snapshot in an environment matching the restore target."],"exampleFix":"// before: restoring without mounting the volume that held /data/file.txt\n// -> journal restore error: failed to open descriptor\n\n// after: mount the same volume / preopen before resuming\n// wasmer run app.wasm --mapdir /data:/host/data  (matching the snapshot layout)","handlingStrategy":"validation","validationCode":"// Before restore, confirm every PathOpen target exists and is accessible\nfor op in journal.path_open_entries() {\n    let p = env.resolve_preopen_path(op.base_fd, &op.path)\n        .ok_or_else(|| anyhow::anyhow!(\"no preopen for base fd {} during restore\", op.base_fd))?;\n    if !std::path::Path::new(&p).exists() {\n        return Err(anyhow::anyhow!(\"restore needs file '{}' which is missing\", p));\n    }\n}","typeGuard":"fn is_openable(p: &std::path::Path) -> bool {\n    use std::os::unix::fs::PermissionsExt;\n    std::fs::metadata(p).map(|m| !m.is_dir()).unwrap_or(false)\n}","tryCatchPattern":"match restore_from_journal(&env, &journal) {\n    Err(e) if e.to_string().contains(\"failed to open descriptor\") => {\n        eprintln!(\"missing file during restore: {e}; remount volumes and retry\");\n        remount_volumes_and_retry()?;\n    }\n    other => other?,\n}","preventionTips":["Mount the same volumes/dirs used at snapshot time before resuming.","Grant matching preopen rights (read/write) to the restored environment.","Watch for case-sensitivity and symlink differences across hosts."],"tags":["wasix","journal","path-open","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"}