← Back to issue list

feat: print error first with `--debug`

View original Github issue

Metadata

Project
craft-application
Number
#897
Type
pull request
State
merged
Author
bepri
Labels
—
Created
Updated
Closed

Current evaluation

Merged #897 in cb109d2c: --debug now prints build errors before opening the shell and repeats them after exit, enabled by canonical/craft-cli#381.

Resolution: closed resolved

Reason: PR #897 was merged as commit cb109d2c. It uses the public error-reporting API from canonical/craft-cli#381 to expose failures before the debug shell opens.

Evaluated by: mr-cal-bot

No scores available.

Issue body

- [x] Have you followed the guidelines for contributing? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `make lint && make test`? - [ ] Have you added an entry to the changelog (`docs/reference/changelog.rst`)? --- When using `--debug` to pack an artifact, the current behavior doesn't actually show the error message until the shell is exited. This change makes it so that the error message is printed twice - once just before entering the shell, and again after the shell is closed. An example from Snapcraft: ```yaml # snapcraft.yaml # (...) parts: my-part: plugin: nil override-build: | echo "hello world!" exit 1 ``` ``` ❯ /snap/bin/snapcraft pack --debug Building my-part :: 'override-build' in part 'my-part' failed with code 1. Building my-part :: Detailed information: :: + echo 'hello world!' :: + exit 1 Building my-part :: Recommended resolution: Review the scriptlet and make sure it's correct. Building my-part :: For more information, check out: https://documentation.ubuntu.com/snapcraft/8.12.0.post0+dirty/reference/plugins/ Building my-part :: Full execution log: '/tmp/snapcraft.log' Launching shell on build environment... snapcraft-testing-snap-amd64-11953991 ../project# exit 'override-build' in part 'my-part' failed with code 1. Detailed information: :: + echo 'hello world!' :: + exit 1 Recommended resolution: Review the scriptlet and make sure it's correct. For more information, check out: https://documentation.ubuntu.com/snapcraft/8.12.0.post0+dirty/reference/plugins/ Failed to run snapcraft in instance Full execution log: '/home/imani/.local/state/snapcraft/log/snapcraft-20250908-131159.893419.log' ``` The logs print the error twice as a consequence (craft-cli doesn't let you skip logging an error message), but one is logged from within the container, denoted by the `::` prefix. This only happens when using `--debug`. Requires https://github.com/canonical/craft-cli/pull/381. CRAFT-4703.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged #897 in cb109d2c: --debug now prints build errors before opening the shell and repeats them after exit, enabled by canonical/craft-cli#381.
stealth/space-bunny-alpha — closed resolved Merged canonical/craft-application#897 to print build errors before and after the --debug shell, using public error reporting from canonical/craft-cli#381.
qwen/qwen3.6-35b-a3b — — Merged updates to print errors immediately when using the debug flag during packing, instead of delaying output until shell exit. Errors now display twice, before and after closure. Requires a craft-cli update and passed all CI checks.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/craft-cli#381 (confidence 100%)

    Required the public error-reporting API used to print the failure before launching the debug shell.

Related issues

Issue Project State Summary Similarity
#866 Print the error when shelling into the build instance with `--debug` craft-application closed Fixed by merged PR canonical/craft-application#897 (commit cb109d2c): with --debug, the build/lifecycle error is now printed before the debug shell opens and again after exit, enabled by canonical/craft-cli#381. Tracked internally as CRAFT-4703.
82%