{"record":{"id":"7fdc51798bfc3d33","repo":"zed-industries/zed","slug":"rmregisterresources-failed-err","errorCode":null,"errorMessage":"RmRegisterResources failed: {err:?}","messagePattern":"RmRegisterResources failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/auto_update_helper/src/updater.rs","lineNumber":335,"sourceCode":"                .chain(std::iter::once(0))\n                .collect()\n        })\n        .collect();\n\n    if wide_paths.is_empty() {\n        log::info!(\"No files to release handles for\");\n        return Ok(());\n    }\n\n    let pcwstr_paths: Vec<PCWSTR> = wide_paths\n        .iter()\n        .map(|p| PCWSTR::from_raw(p.as_ptr()))\n        .collect();\n\n    // Register the files we want to modify\n    let err = unsafe { RmRegisterResources(session, Some(&pcwstr_paths), None, None) };\n    if err.is_err() {\n        anyhow::bail!(\"RmRegisterResources failed: {err:?}\");\n    }\n\n    // Check if any processes are using these files\n    let mut needed: u32 = 0;\n    let mut count: u32 = 0;\n    let mut reboot_reasons: u32 = 0;\n    let _ = unsafe { RmGetList(session, &mut needed, &mut count, None, &mut reboot_reasons) };\n\n    if needed == 0 {\n        log::info!(\"No processes are holding handles to the files\");\n        return Ok(());\n    }\n\n    log::info!(\n        \"{} process(es) are holding handles to the files, requesting release...\",\n        needed\n    );\n","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/auto_update_helper/src/updater.rs#L317-L353","documentation":"After starting a Restart Manager session, the updater registers the Zed files it wants to modify via `RmRegisterResources`. If the API rejects the registration the update aborts with the returned HRESULT. Registration fails on invalid paths, a stale/invalidated session, or service-level errors.","triggerScenarios":"`RmRegisterResources(session, &pcwstr_paths, ...)` fails: one of the wide-string paths is malformed (interior NUL, bad UTF-16 conversion), the session handle is no longer valid, or the RPC channel to the Restart Manager died between `RmStartSession` and this call.","commonSituations":"App directory paths with unusual characters that break UTF-16 conversion; RPC interruptions on busy or unstable machines; antivirus interfering with RM calls; moving the app while the updater runs.","solutions":["Check the updater log's preceding lines: it logs 'No files to release handles for' or the file list — confirm the install path is a normal, stable path without odd characters.","Reboot to reset RPC state and retry the update.","Retry after disabling/changing antivirus configuration that hooks file registration.","Fall back to the full installer to update without the Restart Manager path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Sanity-check paths before handing them to the Restart Manager\nlet all_normal = files.iter().all(|p| p.is_absolute() && p.exists());\nif !all_normal { /* skip RM registration for missing/odd paths */ }","typeGuard":null,"tryCatchPattern":"match register_resources(session, &wide_paths) {\n    Ok(()) => {}\n    Err(err) => log::warn!(\"RmRegisterResources failed ({err:#}); skipping handle release\"),\n}","preventionTips":["Convert paths with `to_owned_wide`/`HSTRING` carefully; reject paths with interior NULs before registration.","Avoid moving the app directory while the updater is running.","Keep the app installed at a stable, plain-ASCII path."],"tags":["windows","restart-manager","hresult","auto-update","updater"],"backgroundTag":"windows-api-hresult-failure","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}