auto-populate apt-cache if empty?
Metadata
Current evaluation
Fixed in PR #1468. Resolved a PackageNotFound error caused by stale apt caches by refreshing the package list before marking packages for installation.
Suggested action: —
No scores available.
Issue body
Hello
would it be possible to automatically populate (apt-get update) the apt-cache if it's empty?
I realise this may not be a major use case, but I've been running snapcraft within a docker container in ci and it was falling over at https://github.com/canonical/craft-parts/blob/1b8787d74e628e84a358efcdafad2995faa1135a/craft_parts/packages/deb.py#L448 because the apt-cache was empty https://github.com/canonical/craft-parts/blob/1b8787d74e628e84a358efcdafad2995faa1135a/craft_parts/packages/apt_cache.py#L301
you have a method already https://github.com/canonical/craft-parts/blob/1b8787d74e628e84a358efcdafad2995faa1135a/craft_parts/packages/deb.py#L379
```
2022-10-07 11:11:00.413 Executing parts lifecycle...
2022-10-07 11:11:00.413 source build packages: {'git'}
2022-10-07 11:11:00.414 source build packages: {'git'}
2022-10-07 11:11:00.414 ignore patterns: ['*.snap', 'parts', 'stage', 'prime']
2022-10-07 11:11:00.414 part build packages: ['ubuntu-dev-tools', 'grub-pc-bin', 'grub-common', 'sbsigntool']
2022-10-07 11:11:00.414 plugin build packages: {'make', 'gcc'}
2022-10-07 11:11:00.415 ignore patterns: ['*.snap', 'parts', 'stage', 'prime']
2022-10-07 11:11:00.415 Requested build-packages: ['gcc', 'git', 'grub-common', 'grub-pc-bin', 'make', 'sbsigntool', 'ubuntu-dev-tools']
2022-10-07 11:11:00.448 Marking sbsigntool (and its dependencies) to be fetched
2022-10-07 11:11:00.449 Cannot find package listed in 'build-packages': sbsigntool
2022-10-07 11:11:00.450 Traceback (most recent call last):
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/packages/deb.py", line 448, in _get_packages_marked_for_installation
2022-10-07 11:11:00.450 apt_cache.mark_packages(set(package_names))
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/packages/apt_cache.py", line 302, in mark_packages
2022-10-07 11:11:00.450 raise errors.PackageNotFound(name_arch)
2022-10-07 11:11:00.450 craft_parts.packages.errors.PackageNotFound: Package not found: sbsigntool.
2022-10-07 11:11:00.450
2022-10-07 11:11:00.450 During handling of the above exception, another exception occurred:
2022-10-07 11:11:00.450 Traceback (most recent call last):
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 165, in run
2022-10-07 11:11:00.450 with self._lcm.action_executor() as aex:
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 281, in __enter__
2022-10-07 11:11:00.450 self._executor.prologue()
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 87, in prologue
2022-10-07 11:11:00.450 self._install_build_packages()
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/executor/executor.py", line 222, in _install_build_packages
2022-10-07 11:11:00.450 packages.Repository.install_packages(sorted(build_packages))
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/packages/deb.py", line 505, in install_packages
2022-10-07 11:11:00.450 marked_packages = cls._get_packages_marked_for_installation(package_names)
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/packages/deb.py", line 261, in wrapped
2022-10-07 11:11:00.450 return method(*args, **kwargs)
2022-10-07 11:11:00.450 File "/snap/snapcraft/current/lib/python3.8/site-packages/craft_parts/packages/deb.py", line 450, in _get_packages_marked_for_installation
2022-10-07 11:11:00.450 raise errors.BuildPackageNotFound(error.package_name)
2022-10-07 11:11:00.450 craft_parts.packages.errors.BuildPackageNotFound: Cannot find package listed in 'build-packages': sbsigntool
```
many thanks
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Fixed in PR #1468. Resolved a PackageNotFound error caused by stale apt caches by refreshing the package list before marking packages for installation. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
35
Complexity:
20
Confidence:
90
Support Request:
10
|
keep open | Request to automatically refresh apt-cache before package installation to prevent BuildPackageNotFound errors in fresh containers. A fix PR has been submitted. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
15
Complexity:
45
Confidence:
90
Support Request:
10
|
keep open | Issue requesting automatic apt-cache population when empty to prevent BuildPackageNotFound errors in fresh environments. A fix has been proposed in PR #1468 and is under review. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
20
Complexity:
30
Confidence:
90
Support Request:
0
|
keep open | Prevents PackageNotFound errors by automatically refreshing the apt cache before package installation. A fix is proposed in PR #1468, which reorders the execution flow to trigger apt-get update earlier. Currently awaiting review. |
Update history
| Date | Change |
|---|---|
| closed |
Related issues
No related issues found above the similarity threshold.