BigPizzaV3/CodexPlusPlus · error · anyhow::Error
GetPackagesByPackageFamily failed with
Error message
GetPackagesByPackageFamily failed with {} What it means
package_full_names_for_family calls the Win32 AppX API GetPackagesByPackageFamily twice: first with null buffers to learn the required count/buffer_length, then with allocated buffers. This bail fires when the FIRST (sizing) call returns an unexpected Win32 error — anything other than APPMODEL_ERROR_NO_PACKAGE, empty success, or ERROR_INSUFFICIENT_BUFFER — meaning the package enumeration could not be started at all.
Solutions
- Check the logged numeric Win32 code (first.0) against Win32 error tables to identify the root cause
- Ensure the AppX-related Windows services (AppX Deployment Service) are running and the AppModel registry state is intact
- Fall back to the non-AppX app directory discovery paths the crate provides (e.g. ProgramFiles-based windows_app_package_roots)
- Verify the code runs on a Windows build that still supports the target package family
Defensive patterns
Strategy: fallback
Validate before calling
// before calling, only run AppX discovery when the environment supports it
let appx_available = cfg!(windows) && std::path::Path::new("C:\\Windows\\SystemApps").exists(); Try / catch
match package_full_names_for_family(family) {
Ok(names) => names,
Err(e) => { log::warn!("AppX enumeration unavailable: {e:#}"); Vec::new() } // fall back to ProgramFiles roots
} Prevention
- Always combine AppX discovery with filesystem-based fallback roots
- Log the raw Win32 status code to diagnose environment-specific failures
- Test on Server/LTSC/CI Windows images where AppX may be absent
When it happens
Trigger: Calling query_registered_windows_packages (used to locate the installed Codex AppX package) on Windows when the first GetPackagesByPackageFamily probe returns a Win32 error code such as E_INVALIDARG, RPC/registry failures, or an unknown family name on unusual SKU/containers.
Common situations: Running on non-standard Windows editions (Server, LTSC) without AppX/AppXDeploymentServer services running; running in sandboxed/CI environments where the AppX registry hive is unavailable; a corrupted AppModel state repository.
Related errors
- GetPackagePathByFullName failed with
- cannot terminate Windows process id
- Cannot verify launcher process identity
- cannot wait for Windows process id
- 拒绝删除文件系统根目录:
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/ebddf399d632e111.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/app_paths.rs:180
.encode_utf16()
.chain(std::iter::once(0))
.collect::<Vec<_>>();
let mut count = 0u32;
let mut buffer_length = 0u32;
let first = unsafe {
GetPackagesByPackageFamily(
PCWSTR(family.as_ptr()),
&mut count,
None,
&mut buffer_length,
PWSTR(std::ptr::null_mut()),
)
};
if first == APPMODEL_ERROR_NO_PACKAGE || (first == ERROR_SUCCESS && count == 0) {
return Ok(Vec::new());
}
if first != ERROR_INSUFFICIENT_BUFFER {
bail!("GetPackagesByPackageFamily failed with {}", first.0);
}
let mut pointers = vec![PWSTR(std::ptr::null_mut()); count as usize];
let mut buffer = vec![0u16; buffer_length as usize];
let status = unsafe {
GetPackagesByPackageFamily(
PCWSTR(family.as_ptr()),
&mut count,
Some(pointers.as_mut_ptr()),
&mut buffer_length,
PWSTR(buffer.as_mut_ptr()),
)
};
if status != ERROR_SUCCESS {
bail!("GetPackagesByPackageFamily failed with {}", status.0);
}
buffer.truncate(buffer_length as usize);
bufferView on GitHub (pinned to b1ed92e5e4)