Snap: Snapcraft currently relies on `libapt` during configure
Metadata
Current evaluation
Resolved in current code: snapcraft_legacy and its configure-time apt import chain were removed; the hook now loads SnapConfig without relying on libapt from the base.
Suggested action: close resolved
Reason: Commit ffb164b7a removed snapcraft_legacy, which caused the configure hook to transitively import apt, and 995f0a3eb removed its dependencies. The current hook imports only snaphelpers and snapcraft.snap_config, snapcraft/__init__.py no longer imports snapcraft.sources, and the snap stages its own apt dependencies.
Evaluated by: mr-cal-bot
Impact:
60
Quick Win:
30
Complexity:
45
Confidence:
97
Actionability:
92
Issue body
### Bug Description
Snapcraft currently relies on `libapt` being available from the base snap, which it has been by accident, we corrected this recently (on core22 and core24 that are in beta/candidate) and then it was reported that Snapcraft now fails to install due to its configure hook importing `apt` which unfortunately relies on `libapt` being available. Furthermore this library has just been taking up space in the base.
We think this is unfortunate due to the fact that snaps are supposed to work in a snap-only system, where `apt` might not even be part of the equation. Right now it may not be a huge problem, but as we move towards a more snap-focused future, this seems very odd, and we would like for Snapcraft to be able to install on a system where `apt` is not available in the base snap.
### To Reproduce
```
$ sudo snap install core22 --candidate
$ sudo snap install snapcraft --classic
```
### Environment
Ubuntu systems that use snap
### snapcraft.yaml
```yaml
N/A
```
### Relevant log output
```shell
$ sudo snap install --classic snapcraft
error: cannot perform the following tasks:
- Run configure hook of "snapcraft" snap if present (run hook "configure":
-----
Traceback (most recent call last):
File "/snap/snapcraft/12961/snap/hooks/configure", line 7, in <module>
from snapcraft.snap_config import SnapConfig
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft/__init__.py", line 23, in <module>
import snapcraft.sources # noqa: F401
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft/sources.py", line 22, in <module>
from snapcraft_legacy.sources import get
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft_legacy/__init__.py", line 340, in <module>
from snapcraft_legacy.internal import repo # noqa
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft_legacy/internal/repo/__init__.py", line 27, in <module>
from ._deb import Ubuntu # noqa
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft_legacy/internal/repo/_deb.py", line 39, in <module>
from .apt_cache import AptCache
File "/snap/snapcraft/current/lib/python3.10/site-packages/snapcraft_legacy/internal/repo/apt_cache.py", line 25, in <module>
import apt
File "/snap/snapcraft/current/lib/python3.10/site-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ImportError: /snap/core22/current/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /lib/x86_64-linux-gnu/libapt-pkg.so.6.0)
-----)
```
```
### Additional context
Original bug report in core-base: https://github.com/canonical/core-base/issues/283
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha |
Impact:
60
Quick Win:
30
Complexity:
45
Confidence:
97
Actionability:
92
|
close resolved | Resolved in current code: snapcraft_legacy and its configure-time apt import chain were removed; the hook now loads SnapConfig without relying on libapt from the base. | |
| stealth/space-bunny-alpha |
Impact:
70
Quick Win:
43
Complexity:
35
Confidence:
97
Actionability:
94
|
close resolved | Configure-hook libapt dependence was valid, but current code no longer eagerly imports snapcraft_legacy; fa7952b4d (PR #6019) removed the failing import path. | |
| qwen/qwen3.6-35b-a3b |
Impact:
100
Quick Win:
20
Complexity:
80
Confidence:
95
Actionability:
100
|
close resolved | Snapcraft configure hook failed due to libapt dependency via snapcraft_legacy. Resolved by removing snapcraft_legacy dependency and refactoring the configure hook. | |
| qwen/qwen3.8-27b |
Impact:
55
Quick Win:
25
Staleness:
45
Complexity:
55
Confidence:
60
Support Request:
10
|
keep open | Snapcraft's configure hook failed to install because importing snapcraft transitively imported apt (via snapcraft_legacy), requiring libapt from the base snap. Maintainers confirmed libapt will be removed in core26; the legacy apt-importing code path has since been removed from the codebase. | |
| qwen/qwen3.8-27b |
Impact:
60
Quick Win:
36
Staleness:
25
Complexity:
40
Confidence:
70
Support Request:
10
|
keep open | Snapcraft's configure hook imports snapcraft, which pulled in snapcraft_legacy and apt/libapt, breaking installation on bases without libapt (core22/24/26). Maintainers confirmed libapt will be removed in core26; snapcraft_legacy has since been removed from the codebase, likely resolving the import chain. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
65
Complexity:
75
Confidence:
85
Support Request:
0
|
keep open | Tracks snapcraft's failure to install due to importing libapt during its configure hook, which conflicts with base snaps removing the library. Maintainers are aware and tracking the dependency conflict against core26 plans. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
50
Complexity:
65
Confidence:
85
Support Request:
10
|
keep open | Snapcraft configure hook fails due to top-level apt imports, which are being removed from Ubuntu base snaps. Currently under developer discussion with confirmed plans to remove libapt in core26, awaiting a code fix. |
Update history
No update history recorded yet.
Related work
-
Caused By:
core-base#283
(confidence 98%)
The linked core-base report documents the libapt removal that exposed Snapcraft's transitive configure-time import.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2285 snapcraft snap: vendor legacy snapcraft | snapcraft | merged | Merged in canonical/snapcraft#2285 (commit 5c1ee3b88), vendoring legacy Snapcraft and dispatching no-base projects to it to preserve backward compatibility. |