Hmbown/CodeWhale · error

Android loaded-image proof changed from

Error message

Android loaded-image proof changed from {:?} to {:?}; refusing to replace the update target

What it means

Immediately before replacing any files, the Android updater re-derives the loaded-image proof (path, device, inode, proof kind) and compares it to the proof captured when the update identity was created. If anything about the running executable changed mid-update, replacing files could act on the wrong binary, so the updater aborts before touching the target.

Solutions

  1. Ensure no other process or updater instance is touching the binary during the update; rerun the update alone.
  2. Restart the newly installed binary by its full path and run the update again from that fresh process.
  3. Check for concurrent automation (CI, sync, package managers) operating on the install directory and serialize updates.
  4. If it recurs, capture both the original and fresh proof (shown in the error) and file a bug.
Defensive patterns

Strategy: try-catch

Validate before calling

// before starting the update, snapshot identity and check the environment is quiet:
let identity = capture_update_identity()?;
// ensure no concurrent writers, then call run_update; on failure, restart fresh

Try / catch

match run_update() {
    Err(e) if e.to_string().contains("loaded-image proof changed") => {
        // abort the swap safely; instruct: restart intended binary by full path, retry
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_primary_update_identity (called from run_update just before the swap) when android_loaded_executable_proof() returns a proof different from identity.android_proof.

Common situations: The binary file was replaced, deleted, or moved between update start and the swap step (racing installer, prior update finishing, user action); the process restarted under a different path; another self-update ran concurrently.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/4d7fe916d816352d. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/update.rs:547

    }
    Ok(())
}

#[cfg(any(target_os = "android", all(test, unix)))]
fn android_device_parts(device: u64) -> (u32, u32) {
    // Linux/Bionic's dev_t encoding, matching makedev(3), major(3), and
    // minor(3). `/proc/self/maps` renders these components in hexadecimal.
    let major = ((device >> 8) & 0xfff) as u32;
    let minor = ((device & 0xff) | ((device >> 12) & 0xfff00)) as u32;
    (major, minor)
}

fn validate_primary_update_identity(identity: &UpdateExecutableIdentity) -> Result<()> {
    #[cfg(target_os = "android")]
    {
        let fresh = android_loaded_executable_proof()?;
        if fresh != identity.android_proof {
            bail!(
                "Android loaded-image proof changed from {:?} to {:?}; refusing to replace the update target",
                identity.android_proof,
                fresh
            );
        }
    }
    let bytes = std::fs::read(&identity.path).context("failed to recheck updater binary")?;
    if sha256_hex(&bytes) != identity.file_hash {
        bail!(
            "The running executable path changed during the update; no further files were replaced. Run the intended executable again by its full path."
        );
    }
    Ok(())
}

/// Only the running binary and copies of those exact bytes are ours to update.
/// Command names alone do not establish ownership of an existing sibling.
fn validate_update_target(target: &Path, identity: &UpdateExecutableIdentity) -> Result<()> {

View on GitHub (pinned to 73e0f67d83)