bug: snapcraft prints insufficient logging when using lxd
Metadata
Current evaluation
Closed as a duplicate of #4499, which was fixed by merged PR #5188 (commit a9fc44093) to surface snapd's snap pack stderr after snapd 2.66 added support.
Resolution: closed superseded
Reason: The maintainer closed the report as a duplicate of #4499 because the underlying snap pack error was blocked on snapd support. PR #5188 later fixed the tracked issue in commit a9fc44093.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
Using LXD or a GitHub action such as [snapcore/action-build](https://github.com/snapcore/action-build/) (which uses LXD under the covers), snapcraft will often print up to, but excluding the most useful error message required for debugging. This is quite frustrating as the error may be a simple typo, or error in migration from core18 to core22 (where files have moved, or rules are more strict).
When using LXD locally, one can `snapcraft --debug` to jump into the container to view more details.
This isn't as straightforward when using LXD as part of a GitHub action run.
To find the error, I added the following conditional step after the standard entry for snapcore/action-build
```yaml
steps:
- uses: actions/checkout@v4
- uses: snapcore/action-build@v1
id: snapcraft
- name: Build failed show log
if: ${{ failure() }}
run: cat /home/runner/.local/state/snapcraft/log/snapcraft*.log
- uses: actions/upload-artifact@v2
with:
name: 'snap'
path: ${{ steps.snapcraft.outputs.snap}}
```
This allowed me to uncover the single line that enabled me to debug the build:-
```
2024-07-22T19:55:52.2549267Z 2024-07-22 19:55:47.371 :: 2024-07-22 19:55:47.013 Detailed information: 2024/07/22 19:55:47.012142 container.go:393: in snap "twinejs": path "launch" does not exist
```
Should:
a) The action cat out the full log on failure?
b) snapcraft write out a more useful error on failure?
While a) is possible and likely simple to implement, b) would benefit GHA users, and local LXD users.
### To Reproduce
Create a yaml that has an error in the path to app command. This will result in an error during 'snap pack' - right at the end of the build. However, the error will not be printed but hidden inside a log file that you can't get to (when it's in a GitHub Action).
I put a hello-world yaml which *should* reproduce the issue, as I intentionally modified the command: line to be incorrect. In theory if you `snapcraft --use-lxd` it will build all the way up to `snap pack` then fail and not tell you why.
### Environment
GitHub Action snapcore/action-build that uses lxd internally.
### snapcraft.yaml
```shell
name: hello
base: core22
version: '2.10'
summary: GNU Hello, the "hello world" snap
description: |
GNU hello prints a friendly greeting.
grade: devel
confinement: devmode
apps:
hello:
command: hello
parts:
gnu-hello:
source: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
plugin: autotools
```
### Relevant log output
```shell
Creating snap package...
Command '['snap', 'pack', '--filename', 'twinejs_2.9.1_amd64.snap', '--compression', 'lzo', PosixPath('/root/prime'), PosixPath('/root/project')]' returned non-zero exit status 1.
Failed to execute pack in instance.
Recommended resolution: Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
Full execution log: '/home/runner/.local/state/snapcraft/log/snapcraft-20240722-190027.468199.log'
Error: The process '/usr/bin/sudo' failed with exit code 1
```
### Additional context
_No response_
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed superseded | Closed as a duplicate of #4499, which was fixed by merged PR #5188 (commit a9fc44093) to surface snapd's snap pack stderr after snapd 2.66 added support. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed by maintainer mr-cal as a duplicate of #4499 (internal ticket CRAFT-3175); the underlying missing `snap pack` stderr was later fixed by merged PR #5188 (commit a9fc44093) once snapd 2.66 exposed it. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as a duplicate of #4499, where missing LXD snap pack errors were tracked. Snapcraft #4499 was later resolved after snapd 2.66 exposed stderr; validation improvements merged in #5164. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as duplicate of #4499. Fixing insufficient LXD logging is blocked until snapd improves snap pack error output to expose critical debugging details. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as a duplicate of issue #4499. The insufficient LXD logging issue is currently blocked by snapd needing to improve snap pack error output. An internal tracking ticket was created. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by #4499. Insufficient LXD logging is blocked by snapd needing to improve snap pack error output. Resolution tracking continues in the referenced issue. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as a duplicate of #4499. Insufficient LXD logging during snap pack failures is currently blocked on snapd to fix error output. Tracking continues in the referenced issue. |
Update history
No update history recorded yet.
Related work
-
Duplicate Of:
canonical/snapcraft#4499
(confidence 100%)
The maintainer explicitly redirected this report to #4499 for consolidated tracking.
-
Likely Fixed By:
canonical/snapcraft#5188
(confidence 98%)
Merged commit a9fc44093 surfaced snapd's snap pack error line after snapd 2.66 added stderr support.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4923 Increase verbosity of `snapcraft`'s missing files error | snapcraft | closed | Closed as a duplicate of #4499; suppressed `snap pack` errors were fixed by merged PR #5188 (commit a9fc44093), which surfaced snapd's stderr. | |
| #1647 lxd: better surfacing of errors | snapcraft | merged | Merged in snapcraft#1647 as commit 71f48bdc9, improving LXD error handling so callers return silent, correctly coded errors without printing messages twice. | |
| #4870 snapcraft pack error obtuse on snapd errors | snapcraft | closed | Closed as a duplicate of #4548, which was tracked by #4499; hidden snapd pack diagnostics were fixed by merged PR #5188 (a9fc44093). |