← Back to issue list

rockcraft needs to update apt sources before installing build-packages

View original Github issue

Metadata

Project
rockcraft
Number
#1005
Type
issue
State
open
Author
vpa1977
Labels
Created
Updated
Closed

Current evaluation

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.

Suggested action: keep open

Reason: Maintainers actively triaged this (gcomneno, 2026-02-22 and 2026-03-31) and identified the root cause as upstream craft-parts: Ubuntu.install_packages() marked packages before apt-get update, causing BuildPackageNotFound on stale caches. The fix was merged in canonical/craft-parts#1468 (commit c2836c97), and rockcraft already depends on craft-parts>=2.35.0, so the issue should stay open until the fixed craft-parts release is confirmed in a rockcraft release and the reporter verifies.

Impact: 55 Quick Win: 38.5 Staleness: 25 Complexity: 30 Confidence: 80 Support Request: 5

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
qwen/qwen3.8-27b
Impact: 55
Quick Win: 38.5
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.
qwen3.6-35b-a3b-mtp-q6
Staleness: 50
Complexity: 20
Confidence: 85
Support Request: 5
keep open Rockcraft fails to install build-packages due to stale apt caches, as sources are not updated before package resolution. Identified as an upstream craft-parts bug. A fix is proposed in craft-parts#1468 and awaits upstream review.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-parts#1468 (confidence 85%)

    Merged PR 'fix(deb): refresh apt cache before marking packages' directly addresses the stale-cache BuildPackageNotFound reported here; rockcraft pins craft-parts>=2.35.0.

  • Related To: canonical/craft-parts#292 (confidence 75%)

    Upstream craft-parts issue about auto-populating apt-cache when empty, closed as fixed by PR #1468; same stale-cache failure mode.

Related issues

Issue Project State Summary Similarity
#28 Stage-packages fails at unpack_stage_packages when installing some packages rockcraft closed Fixed by integrating craft-parts PR #215. The unpack_stage_packages ValueError during rockcraft pack when installing packages like ca-certificates is resolved.
71%
#812 rockcraft insists on rebuilding part that has not changed rockcraft open Rockcraft rebuilds the mariadb part when the unrelated scripts part changes, despite no dependency between them. Reported 565 days ago with no maintainer response, labels, or activity; the rebuild logic lives in craft-parts, not rockcraft.
70%