alpm.rs icon indicating copy to clipboard operation
alpm.rs copied to clipboard

[Help] WrongArgs error when using the `trans_add_pkg` function.

Open hbacelar8 opened this issue 5 months ago • 1 comments

I'm trying to establish a transaction step by step and I keep getting a WrongArgs error when using the trans_add_pkg passing a &Package. Here's an example:

use alpm::{Alpm, Error, SigLevel, TransFlag};

fn main() -> Result<(), Error> {
    let alpm = Alpm::new("/", "/var/lib/pacman")?;
    alpm.register_syncdb("core", SigLevel::USE_DEFAULT)?;
    alpm.register_syncdb("extra", SigLevel::USE_DEFAULT)?;

    alpm.trans_init(TransFlag::NO_LOCK)?;

    let pkg = alpm.localdb().pkg("tevent")?;
    alpm.trans_add_pkg(pkg)?;

    let pkgs = alpm.trans_add();

    for pkg in pkgs {
        println!("{}", pkg.name());
    }

    Ok(())
}

If, instead of adding a singular package, I call the sync_sysupgrade, it works fine and all upgradable packages are successfully added.

Am I doing something wrong? A WrongArgs in this case really gives me no clue of what it could be.

Thanks.

hbacelar8 avatar Jul 21 '25 20:07 hbacelar8