{"record":{"id":"4d217a500904e647","repo":"unicity-aos/aos-ce","slug":"standalone-runtime-has-no-existing-system-lock-refusing-an","errorCode":null,"errorMessage":"standalone runtime has no existing system lock; refusing an unlocked migration","messagePattern":"standalone runtime has no existing system lock; refusing an unlocked migration","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/unicity-aos-bootstrap/src/migration.rs","lineNumber":157,"sourceCode":"        let value = String::deserialize(deserializer)?;\n        Self::parse(&value).map_err(D::Error::custom)\n    }\n}\n\nstruct MigrationLock {\n    _file: File,\n}\n\nstruct SourceRuntimeLock {\n    _file: File,\n}\n\nimpl SourceRuntimeLock {\n    fn acquire(source: &Path) -> io::Result<Self> {\n        let path = source.join(\"run/system.lock\");\n        let path_metadata = fs::symlink_metadata(&path).map_err(|error| {\n            if error.kind() == io::ErrorKind::NotFound {\n                io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"standalone runtime has no existing system lock; refusing an unlocked migration\",\n                )\n            } else {\n                error\n            }\n        })?;\n        if path_metadata.file_type().is_symlink() || !path_metadata.is_file() {\n            return invalid(\"standalone runtime system lock must be a real regular file\");\n        }\n        let file = OpenOptions::new().read(true).write(true).open(&path)?;\n        let file_metadata = file.metadata()?;\n        if !file_metadata.is_file() || !same_file(&path_metadata, &file_metadata) {\n            return invalid(\"standalone runtime system lock changed while it was opened\");\n        }\n        file.try_lock_exclusive().map_err(|error| {\n            if error.kind() == io::ErrorKind::WouldBlock {\n                io::Error::new(","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/crates/unicity-aos-bootstrap/src/migration.rs#L139-L175","documentation":"`SourceRuntimeLock::acquire` opens `<source>/run/system.lock` before migrating a standalone runtime. If the symlink metadata lookup fails with `NotFound`, the library refuses to proceed: migrating a source runtime that has no system lock would not be guarded against an active runtime, so it raises `InvalidInput`. The lock must already exist to prove the source is a real standalone runtime.","triggerScenarios":"Calling the migration entry point (which internally calls `SourceRuntimeLock::acquire`) against a source path whose `run/system.lock` file does not exist — e.g. wrong source path, never-started runtime, or a runtime layout where `run/` is missing.","commonSituations":"Pointing the migration at a stale or half-deleted installation, migrating a containerized/systemd runtime that stores its lock elsewhere, or a typo in the source directory passed on the command line.","solutions":["Verify the source path is the standalone runtime root containing `run/system.lock` (e.g. `ls <source>/run/system.lock`) and correct the path.","If the runtime should be running/initialized, start it once so the runtime creates `run/system.lock`, then retry the migration.","If the lock was deleted, restore the runtime layout (or reinstall) rather than hand-creating an empty lock, since the file must be a real regular file matching metadata.","Ensure you are migrating the right runtime kind — a non-standalone runtime may legitimately lack this lock and is not a valid migration source."],"exampleFix":"// before\nmigrate_runtime(Path::new(\"/opt/wrong-runtime\"), ...);\n\n// after\nlet source = Path::new(\"/opt/unicity-runtime\");\nassert!(source.join(\"run/system.lock\").exists(), \"missing run/system.lock\");\nmigrate_runtime(source, ...);","handlingStrategy":"validation","validationCode":"let lock = source.join(\"run/system.lock\");\nif !lock.symlink_metadata().map(|m| m.is_file()).unwrap_or(false) {\n    return Err(anyhow!(\"{} is not a standalone runtime (missing run/system.lock)\", source.display()));\n}","typeGuard":null,"tryCatchPattern":"match err.downcast_ref::<io::Error>() {\n    Some(e) if e.kind() == io::ErrorKind::InvalidInput && e.to_string().contains(\"no existing system lock\") => /* point at correct runtime root */,\n    _ => return Err(err),\n}","preventionTips":["Verify the runtime root contains `run/system.lock` before migration.","Start the runtime once before migrating so the runtime layout is complete.","Distinguish runtime kinds — only standalone runtimes with this lock are valid migration sources."],"tags":["filesystem","locking","migration","rust"],"backgroundTag":"file-not-found","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}