canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 446 forks source link

Failures when running `snap pack` don't get sent to the user. #4499

Open lengau opened 11 months ago

lengau commented 11 months ago

Bug Description

If snap pack fails, the error message (which is often helpful in determining why it failed) is hidden unless you enable debug logging or look in the detailed log file. Instead, the error message shows the specific command that was run in the instance (which isn't particularly useful to the user).

To Reproduce

Run snapcraft pack with the provided snapcraft.yaml.

Environment

Kubuntu 23.04

snapcraft.yaml

name: my-snap-name # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  thing:
    command: this/file/does/not/exist

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: nil

Relevant log output

lengau@ratel:~/tmp$ snapcraft pack
Launching instance...                                                                                                                      
Executed: pull my-part                                                                                                                     
Executed: build my-part                                                                                                                    
Executed: stage my-part                                                                                                                    
Executed: prime my-part                                                                                                                    
Executed parts lifecycle                                                                                                                   
Generated snap metadata                                                                                                                    
Command '['snap', 'pack', '--filename', 'my-snap-name_0.1_amd64.snap', '--compression', 'xz', 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/lengau/.local/state/snapcraft/log/snapcraft-20231215-111314.031750.log'

Additional context

No response

lengau commented 11 months ago

Full process log:

snapcraft-20231215-111314.031750.log

My suggestion for handling snap pack errors would be something along the lines of:

Packing snap failed with error code {returncode}. Full command output is available in the execution log. 
Final error message was: {last_line}

Since snap pack often has very long, possibly redundant output, this provides a clearer error message whilst still limiting the output shown in brief mode to only what is typically a summary.

mr-cal commented 6 months ago

Same problem in https://launchpad.net/~liushuyu-011/+snap/deno-snap/+build/2472567. This built takes 34 hours and there is no useful output

@liushuyu

syncronize-issues-to-jira[bot] commented 6 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2912.

This message was autogenerated

mr-cal commented 3 months ago

For context:

  1. 4413 was created from a report Gustavo, where too much unformatted information was displayed in brief mode

  2. This prompted #4424 and #4434
  3. Those PRs in turn caused bug reports for not enough information being displayed (#4499, #4548, #4923)

@tigarmo, @sergiusens, and I agreed that we need to show the error in brief mode with better formatting and as a SnapdError. This is blocked by snapd work: https://warthogs.atlassian.net/browse/SNAPDENG-23795 and https://bugs.launchpad.net/snapd/+bug/2070926?comments=all

mr-cal commented 3 months ago

Two more bug reports for this issue:

mr-cal commented 3 months ago

Another bug report for this issue with an context of how it makes debugging CI builds very challenging: https://github.com/canonical/snapcraft/issues/4933

lengau commented 2 months ago

A note on the Launchpad builds: this is even more of a problem on Launchpad than locally, as the logs don't get included in the failed output.

Red-Hammer commented 2 months ago

Bumping this because I've spent far too long not knowing why things are failing. The current output is entirely useless and anxiety inducing, because it doesn't tell you what's wrong. Like a child who can't use words but can huff. I get huffed at enough, I don't want snap to huff at me too

mr-cal commented 1 month ago

Another report where Launchpad builds on uncommon architectures (riscv64) produce unhelpful error messages: https://bugs.launchpad.net/snapcraft/+bug/2080728

mr-cal commented 1 month ago

Once snapd 2.66 is released, snapcraft will be able to show the stderr from snapd.

Snapcraft will need to filter the stderr and only show the line that begins with error: as snapd still outputs internal go errors.