← Back to issue list

repo: catch error due to broken build packages

View original Github issue

Metadata

Project
snapcraft
Number
#2023
Type
pull request
State
merged
Author
kalikiana
Labels
Created
Updated
Closed

Current evaluation

Resolved broken build package errors by introducing BuildPackagesNotInstalledError and falling back to apt-get for detailed conflict messages. Merged after reviewer approval and passing CI checks.

Suggested action:

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)? - [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)? - [x] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh unit`? ----- This PR modifies `repo._deb` to handle failure to `sudo apt-get install` new packages as [reported in the forum](https://forum.snapcraft.io/t/unable-to-correct-problems-you-have-held-broken-packages/4584). Typically this occurs when packages have conflicting dependencies. Currently Snapcraft just bails out with a stack trace in this case. The Python Apt bindings have a heuristic that's similar to what `apt-get` does but exposes less information. So if it fails to resolve conflicts in `apt.Package.mark_install` we get a `SystemError` with not enough details to produce a sensible error message. By specifying `auto_fix=False` we can always fall-through to `apt-get` which will show a verbose error message so just referring to the packages we couldn't install is still clear enough even if we don't know which one(s) specifically failed. For this case I'm introducing a new `BuildPackagesNotInstalledError`. The following new tests are being added: - tests.unit.repo.test_deb.test_broken_package_apt_install - To verify that `apt-get install` failing with a `CalledProcessError` is handled. I locally ran the tests: - `./runtests.sh tests/unit` with unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576), `tests.unit.test_mangling.TestClearExecstack.test_execstack_clears` and `tests.unit.test_elf`. - `./runtests.sh tests/integration` with one unrelated failure in [tests.integration.general.test_parser.TestParserWikis](https://bugs.launchpad.net/snapcraft/+bug/1752580) - `./runtests.sh static`: Everything passed Manual test steps: - cd tests/integration/snaps/basic - Add this line to `snap/snapcraft.yaml`: `build-packages: [cpp-arm-linux-gnueabihf, gcc-5-arm-linux-gnueabihf, gcc-arm-linux-gnueabihf, gcc-multilib]` - snapcraft - Observe that you get an error that looks like this: `The following packages have unmet dependencies:` ` gcc-5-arm-linux-gnueabihf : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed` ` gcc-multilib : Conflicts: gcc-5-arm-linux-gnueabihf` ` Conflicts: gcc-5-arm-linux-gnueabihf:i386` `Could not install all requested build packages: gcc-5-arm-linux-gnueabihf gcc-arm-linux-gnueabihf gcc-multilib`

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Resolved broken build package errors by introducing BuildPackagesNotInstalledError and falling back to apt-get for detailed conflict messages. Merged after reviewer approval and passing CI checks.
qwen3.6-35b-a3b-mtp-q6 Merged fix handling broken build packages during apt installation. Introduces BuildPackagesNotInstalledError and falls back to apt-get for verbose conflict messages instead of crashing with a stack trace. Includes unit tests.
qwen3.6-35b-a3b-mtp-q6 Merged fix addressing Snapcraft crashes from broken build packages. Introduces BuildPackagesNotInstalledError and falls back to apt-get for clear dependency conflict messages instead of unhandled SystemError stack traces.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#3221 repo: install requested build-package versions snapcraft merged Merged fix for unimplemented build-package version installation. Explicitly specifies apt package versions and enables downgrades to resolve LP: #1887960. Approved and passed CI checks.
75%
#1788 repo: error for packages with broken dependencies snapcraft merged Merged changes replace silent failures with a clear error message for packages containing broken dependencies, resolving bug 1686481. Approved after minor test adjustments.
74%
#891 repo: apt-mark new build-packages as automatically installed snapcraft merged Merged. Marks new build packages as automatically installed to enable cleanup via apt-get autoremove. Approved, updated with integration tests, rebased to resolve conflicts, minor fixes applied, and merged.
72%
#1185 repo: add version support for build-packages snapcraft merged Merged after adjusting apt_cache to exclude package versions, adding version support for build-packages. Rebased changes were re-applied and tests passed. Approved by two reviewers.
72%
#3411 repo: only install build packages marked for installation snapcraft merged Merged a fix updating apt_cache.get_marked_packages() to exclude packages marked for deletion. The function now only returns packages intended for installation, letting apt handle removals. Approved and merged after passing CI.
72%
#3035 repo: fix resolution of virtual build packages snapcraft merged Merged fix for virtual build package resolution regression. Ensures proper resolution and versioning persistence for build and stage packages, adds logging, and includes unit and spread tests. Approved and passed CI.
70%