← Back to issue list

BuildPackageNotFound for valid packages when snap uses core24 on Ubuntu 26.04 (libapt ABI mismatch)

View original Github issue

Metadata

Project
craft-parts
Number
#1554
Type
issue
State
open
Author
lengau
Labels
Type: Bug
Created
Updated
Closed
—

Current evaluation

core24 snap builds on Ubuntu 26.04 falsely raise BuildPackageNotFound; regression coverage exists, but the claimed apt ABI/cache-format cause is disputed and no fix is merged.

Suggested action: keep open

Reason: The report documents 30+ repeated CI failures, exact environment details, and reproducer commit 82cbb54 adding empty-cache regression coverage. However, mr-cal showed that apt 2.7.14 and 3.3.1 both use cache version 16 and reported an LXD reproducer behaving the same on 24.04 and 26.04, so the ABI root cause is not confirmed and requires further investigation.

Evaluated by: mr-cal-bot

Impact: 54 Quick Win: 12 Complexity: 65 Confidence: 82 Actionability: 64

Issue body

## Summary When a snap built on `core24` (which bundles `libapt-pkg.so.6.0` / python-apt 2.7.x) runs in `--destructive-mode` on **Ubuntu 26.04**, craft-parts raises `BuildPackageNotFound` for packages that **do** exist on that system. The root cause is an **ABI mismatch**: the snap's python-apt was compiled against `libapt-pkg.so.6.0` (apt 2.x, Ubuntu 24.04), but Ubuntu 26.04 ships **apt 3.x** (`libapt-pkg.so.7.0`). The snap cannot correctly read the host's apt package lists. ## Observed error ``` 2026-04-21 21:26:37.718 Cannot find package listed in 'build-packages': python3-dev craft_parts.packages.errors.BuildPackageNotFound: Cannot find package listed in 'build-packages': python3-dev ``` This occurs even though `python3-dev` is a valid package on Ubuntu 26.04. The same error occurs for `python3-venv`. ## Steps to reproduce 1. Build a snap using `base: core24` 2. Install and run that snap on Ubuntu 26.04 (which has apt 3.x / libapt-pkg.so.7.0) 3. Run `charmcraft pack --destructive-mode` on a charm that uses the `python` or `uv` plugin (both of which add `python3-dev` to `build-packages`) 4. Observe `BuildPackageNotFound: python3-dev` ## Root cause analysis ### ABI mismatch ``` # Snap's apt_pkg extension module links against: libapt-pkg.so.6.0 => /snap/core24/current/lib/x86_64-linux-gnu/libapt-pkg.so.6.0 # Ubuntu 26.04 system libapt: /usr/lib/x86_64-linux-gnu/libapt-pkg.so.7.0 (apt 3.2.0) ``` The python-apt bundled in the snap (version `2.7.7+ubuntu5`) was compiled against core24's `libapt-pkg.so.6.0`. On Ubuntu 26.04, `/snap/core24/current/lib/x86_64-linux-gnu/libapt-pkg.so.6.0` resolves to the 24.04 library. ### configure_apt sets Dir to a non-existent path In `AptCache.configure_apt()`, when running inside a snap, the code sets: ```python apt_dir = os.path.join(snap_dir, "usr", "lib", "apt") apt_pkg.config.set("Dir", apt_dir) ``` However, the charmcraft snap does **not** include `usr/lib/apt`. This path does not exist, so apt's method/solver resolution breaks. The code then sets `Dir::State` to `/var/lib/apt` to point at the host's package lists, but because `Dir` is pointing at a missing path, the relative paths for `Dir::State::Lists` may not resolve correctly. ### apt binary cache format version mismatch Ubuntu 26.04's `/var/cache/apt/pkgcache.bin` reports **cache data version 16.0**. The apt 2.x library (bundled in the snap via core24) likely supports an older cache version. Even if the cache can be opened, package lookups may silently fail or return no results. ### Evidence from charmcraft CI The `tests/spread/ubuntu-26.04/charm:platforms` and `tests/spread/ubuntu-26.04/charm:uv` spread tests have been failing **consistently** on every CI run for months (30+ consecutive failures as of 2026-04-22). The same error appears each time. Tests on 18.04, 20.04, 24.04, and 25.10 all pass. ## Workaround None currently available without rebuilding the snap against `core26` (which would bundle `libapt-pkg.so.7.0`). ## Suggested fix craft-parts should handle the case where the snap's bundled python-apt cannot read the host's apt cache. Options: 1. **Document the core requirement**: craft-parts should document that the application snap's base must match the host Ubuntu series for `install_packages` / `build-packages` to work. Raise a clear error with a helpful message instead of `BuildPackageNotFound`. 2. **Detect apt ABI mismatch**: Before attempting to use python-apt's cache, check that the `libapt-pkg.so` ABI version used by the bundled python-apt matches the host's libapt. If not, fall back to shelling out to `apt-cache show <package>` or skip the pre-check entirely. 3. **Don't fail on cache-open errors**: If `apt.cache.Cache(rootdir="/")` fails or returns an empty cache (zero packages), treat it as "cache unavailable" rather than "package not found", and defer to `apt-get install` to produce the real error. ## Environment - Host: Ubuntu 26.04 (apt 3.2.0, libapt-pkg.so.7.0) - Snap base: core24 (bundles libapt-pkg.so.6.0, python-apt 2.7.7+ubuntu5) - craft-parts version: 2.29.0 - charmcraft version: 4.2.x (snap) - Failed tasks: `tests/spread/ubuntu-26.04/charm:platforms`, `tests/spread/ubuntu-26.04/charm:uv` - CI run demonstrating failures: https://github.com/canonical/charmcraft/actions/runs/24746125338/job/72401080653

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 54
Quick Win: 12
Complexity: 65
Confidence: 82
Actionability: 64
keep open core24 snap builds on Ubuntu 26.04 falsely raise BuildPackageNotFound; regression coverage exists, but the claimed apt ABI/cache-format cause is disputed and no fix is merged.
qwen/qwen3.6-35b-a3b
Impact: 70
Quick Win: 22
Complexity: 60
Confidence: 70
Actionability: 80
keep open BuildPackageNotFound error when core24 snap runs on Ubuntu 26.04 due to libapt ABI mismatch. Has reproducer branch and active maintainer discussion; root cause still debated.
qwen/qwen3.8-27b
Impact: 60
Quick Win: 15
Staleness: 15
Complexity: 75
Confidence: 70
Support Request: 5
keep open BuildPackageNotFound for valid packages when a core24 snap runs on Ubuntu 26.04 (apt ABI mismatch). Actively under discussion: a reproducer branch exists, and a maintainer (mr-cal) is challenging the ABI root-cause theory, noting the error also reproduces on 24.04 without apt-get update.
qwen/qwen3.6-35b-a3b
Staleness: 10
Complexity: 75
Confidence: 90
Support Request: 5
keep open Bug report detailing BuildPackageNotFound errors when core24 snaps run on Ubuntu 26.04 due to libapt ABI mismatch. Currently under active maintainer investigation with counter-reproducers and test branches provided.
qwen3.6-35b-a3b-mtp-q6
Staleness: 5
Complexity: 70
Confidence: 90
Support Request: 10
keep open craft-parts raises BuildPackageNotFound on Ubuntu 26.04 when running core24 snaps due to suspected libapt ABI mismatch. Maintainers are actively investigating root cause and reviewing reproducer tests.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.