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

  1. Check the logged numeric Win32 code (first.0) against Win32 error tables to identify the root cause
  2. Ensure the AppX-related Windows services (AppX Deployment Service) are running and the AppModel registry state is intact
  3. Fall back to the non-AppX app directory discovery paths the crate provides (e.g. ProgramFiles-based windows_app_package_roots)
  4. 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

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


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);
    buffer

View on GitHub (pinned to b1ed92e5e4)