rockcraft needs to update apt sources before installing build-packages
Metadata
Current evaluation
Rockcraft 1.15.0 could fail build-package resolution with a stale apt cache; craft-parts PR #1468 now refreshes apt metadata before marking packages.
Suggested action: close resolved
Reason: The traceback is in craft-parts' Ubuntu package-install path, which marked packages before refreshing apt metadata. Merged craft-parts PR #1468, commit c2836c97, refreshes the cache before marking and adds regression tests; upstream issue #292 was closed by that fix, and no Rockcraft-specific apt logic needs changing.
Evaluated by: mr-cal-bot
Impact:
52
Quick Win:
43
Complexity:
14
Confidence:
94
Actionability:
96
Issue body
### Bug Description
I am building openjdk-25 jre rock that uses openjdk-25-jdk-headless build package.
Rockcraft reports `Cannot find package listed in 'build-packages': openjdk-25-jdk-headless` when building rock.
The package can be installed with `apt-get` in `override-build`.
### To Reproduce
1. rockcraft pack
### Environment
```
$ rockcraft version
rockcraft 1.15.0
```
rockcraft uses lxd backend.
### rockcraft.yaml
```yaml
name: jre
version: 25-edge
base: bare
build-base: ubuntu@24.04
platforms:
amd64:
summary: OpenJDK 25 headless runtime environment
description: |
This rock provides OpenJDK 25 runtime environment including
parts:
dependencies:
plugin: nil
build-packages:
- openjdk-25-jdk-headless
```
### Relevant log output
```shell
:: 2025-10-14 08:18:03.935 Initialising lifecycle
:: 2025-10-14 08:18:03.936 part build packages: ['openjdk-25-jdk-headless']
:: 2025-10-14 08:18:03.936 Installing build-packages
:: 2025-10-14 08:18:03.936 get repository attribute: attr=install_packages, repository:<class 'craft_parts.packages.deb.Ubuntu'>
:: 2025-10-14 08:18:03.936 Installing packages using apt: ['openjdk-25-jdk-headless']
:: 2025-10-14 08:18:04.649 Marking openjdk-25-jdk-headless (and its dependencies) to be fetched
:: 2025-10-14 08:18:04.649 Cannot find package listed in 'build-packages': openjdk-25-jdk-headless
:: 2025-10-14 08:18:04.651 Traceback (most recent call last):
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 491, in _get_packages_marked_for_installation
:: 2025-10-14 08:18:04.651 apt_cache.mark_packages(set(package_names))
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/apt_cache.py", line 307, in mark_packages
:: 2025-10-14 08:18:04.651 raise errors.PackageNotFound(name_arch)
:: 2025-10-14 08:18:04.651 craft_parts.packages.errors.PackageNotFound: Package not found: openjdk-25-jdk-headless.
:: 2025-10-14 08:18:04.651
:: 2025-10-14 08:18:04.651 The above exception was the direct cause of the following exception:
:: 2025-10-14 08:18:04.651 Traceback (most recent call last):
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 306, in run
:: 2025-10-14 08:18:04.651 self._exec(actions)
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 325, in _exec
:: 2025-10-14 08:18:04.651 with self._lcm.action_executor() as aex:
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 333, in __enter__
:: 2025-10-14 08:18:04.651 self._executor.prologue()
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 101, in prologue
:: 2025-10-14 08:18:04.651 self._install_build_packages()
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 278, in _install_build_packages
:: 2025-10-14 08:18:04.651 packages.Repository.install_packages(sorted(build_packages))
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 548, in install_packages
:: 2025-10-14 08:18:04.651 marked_packages = cls._get_packages_marked_for_installation(package_names)
:: 2025-10-14 08:18:04.651 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 295, in wrapped
:: 2025-10-14 08:18:04.651 return method(*args, **kwargs)
:: 2025-10-14 08:18:04.651 ^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 493, in _get_packages_marked_for_installation
:: 2025-10-14 08:18:04.651 raise errors.BuildPackageNotFound(error.package_name) from error
:: 2025-10-14 08:18:04.651 craft_parts.packages.errors.BuildPackageNotFound: Cannot find package listed in 'build-packages': openjdk-25-jdk-headless
2025-10-14 08:18:04.993 Executing on host: lxc --project rockcraft config device show local:rockcraft-jre-amd64-33199546
2025-10-14 08:18:05.067 Executing on host: lxc --project rockcraft config device remove local:rockcraft-jre-amd64-33199546 disk-/root/project
2025-10-14 08:18:05.175 Executing on host: lxc --project rockcraft config device remove local:rockcraft-jre-amd64-33199546 disk-/tmp/craft-state
2025-10-14 08:18:05.283 Executing on host: lxc --project rockcraft stop local:rockcraft-jre-amd64-33199546
2025-10-14 08:18:09.434 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:09.760 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:10.066 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:10.382 Executing on host: lxc --project rockcraft config set local:rockcraft-jre-amd64-33199546 user.craft_providers.status FINISHED
2025-10-14 08:18:10.500 Failed to run rockcraft in instance
2025-10-14 08:18:10.504 Traceback (most recent call last):
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/provider.py", line 469, in run_managed
2025-10-14 08:18:10.504 instance.execute_run( # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_providers/lxd/lxd_instance.py", line 257, in execute_run
2025-10-14 08:18:10.504 return self.lxc.exec(
2025-10-14 08:18:10.504 ^^^^^^^^^^^^^^
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 393, in exec
2025-10-14 08:18:10.504 return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2025-10-14 08:18:10.504 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.504 File "/snap/rockcraft/current/usr/lib/python3.12/subprocess.py", line 571, in run
2025-10-14 08:18:10.504 raise CalledProcessError(retcode, process.args,
2025-10-14 08:18:10.504 subprocess.CalledProcessError: Command '['lxc', '--project', 'rockcraft', 'exec', 'local:rockcraft-jre-amd64-33199546', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'ROCKCRAFT_DEBUG=False', 'ROCKCRAFT_LXD_REMOTE=local', 'ROCKCRAFT_LAUNCHPAD_INSTANCE=production', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=BRIEF', 'rockcraft', 'pack']' returned non-zero exit status 1.
2025-10-14 08:18:10.504
2025-10-14 08:18:10.504 The above exception was the direct cause of the following exception:
2025-10-14 08:18:10.504 Traceback (most recent call last):
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/application.py", line 663, in run
2025-10-14 08:18:10.505 return_code = self._run_inner()
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/application.py", line 640, in _run_inner
2025-10-14 08:18:10.505 return_code = dispatcher.run() or os.EX_OK
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2025-10-14 08:18:10.505 return self._loaded_command.run(self._parsed_command_args)
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/base.py", line 222, in run
2025-10-14 08:18:10.505 result = self._run(parsed_args, **kwargs) or result
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 619, in _run
2025-10-14 08:18:10.505 return super()._run(parsed_args=parsed_args, step_name=step_name)
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 232, in _run
2025-10-14 08:18:10.505 self._run_manager_for_build_plan(fetch_service_policy)
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 97, in _run_manager_for_build_plan
2025-10-14 08:18:10.505 provider.run_managed(build, bool(fetch_service_policy))
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/provider.py", line 476, in run_managed
2025-10-14 08:18:10.505 raise craft_providers.ProviderError(
2025-10-14 08:18:10.505 craft_providers.errors.ProviderError: Failed to run rockcraft in instance
2025-10-14 08:18:10.505 Full execution log: '/home/vladimirp/.local/state/rockcraft/log/rockcraft-20251014-081734.765385.log'
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha |
Impact:
52
Quick Win:
43
Complexity:
14
Confidence:
94
Actionability:
96
|
close resolved | Rockcraft 1.15.0 could fail build-package resolution with a stale apt cache; craft-parts PR #1468 now refreshes apt metadata before marking packages. | |
| qwen/qwen3.6-35b-a3b |
Impact:
70
Quick Win:
39
Complexity:
30
Confidence:
95
Actionability:
80
|
close resolved | Rockcraft fails to install build-packages due to stale apt cache. Fixed upstream in craft-parts#1468 which refreshes apt cache before marking packages. | |
| qwen/qwen3.8-27b |
Impact:
55
Quick Win:
38
Staleness:
25
Complexity:
30
Confidence:
80
Support Request:
5
|
keep open | Rockcraft fails to install build-packages (e.g. openjdk-25-jdk-headless) because craft-parts marks packages before refreshing the apt cache. Maintainers triaged it as an upstream craft-parts bug; fix merged in craft-parts#1468, now awaiting dependency bump/release. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
45
Complexity:
20
Confidence:
90
Support Request:
10
|
keep open | Rockcraft fails to find build-packages due to missing apt update before installation. Maintainers identified it as an upstream craft-parts bug with a proposed fix. Currently awaiting upstream resolution. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
45
Complexity:
30
Confidence:
85
Support Request:
5
|
keep open | Rockcraft fails to install build-packages due to stale apt cache. Maintainers identified it as an upstream craft-parts bug with a proposed fix. Currently awaiting upstream resolution or cross-repo linking. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
45
Complexity:
60
Confidence:
85
Support Request:
10
|
keep open | Rockcraft build fails due to stale apt cache when installing build-packages. Maintainers identified this as an upstream craft-parts issue with a proposed fix. Awaiting upstream resolution. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-parts#1468
(confidence 100%)
Merged commit c2836c97 refreshes apt metadata before package resolution and adds tests for the stale-cache failure.
-
Related To:
canonical/craft-parts#292
(confidence 97%)
The upstream empty or stale apt-cache issue was closed by the same fix.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #129 requirements: update craft-parts to 1.15.1 | rockcraft | merged | Merged as b6b420bf, updating craft-parts to 1.15.1 to fix overlay device nodes and package-list updates on ubuntu:22.04; resolves rockcraft#117. | |
| #32 requirements: update dependencies | rockcraft | merged | Merged in canonical/rockcraft#32 (commit 261961c1), updating dependencies to include the craft-parts symlink fix and resolve the stage-package installation failure in #28. | |
| #178 `rockcraft` crashes at the `update apt cache` step | rockcraft | open | apt-get update inside LXD build instance fails on GitHub's ubuntu-22.04 runners; maintainers traced it to Docker/LXD iptables clash, not a rockcraft bug, and point to canonical/setup-lxd and canonical/craft-actions rockcraft-pack as fix (now documented). |