← Back to issue list

Scriptlets should run with "-e" shell flag

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1707189
Type
issue
State
closed
Author
~jamesh
Labels
scripts
Created
Updated
Closed

Current evaluation

Scriptlets now stop on command failures; fixed by snapcore/snapcraft PR #1545 in commit 3a18cc87a.

Resolution: closed resolved

Reason: Merged PR snapcore/snapcraft#1545 added scriptlet error checking in commit 3a18cc87a, preventing execution from continuing after a failed command.

Evaluated by: mr-cal-bot

No scores available.

Issue body

As discussed on the forum, scriptlets should run with the "-e" shell flag (i.e. fail if any command returns non zero): https://forum.snapcraft.io/t/scripting-and-setting-metadata-in-snapcraft/1447/2?u=jamesh At the moment, if I put something like the following in my snapcraft.yaml, the build will succeed: install: | command_that_fails command_that_succeeds Execution continues past the first failed command, and the second successful command causes the scriptlet to return 0. Situations like this almost always indicate a bug, and for the cases where the exit code should be ignored there are work arounds (e.g. run "set +e", or append "||:" to the end of the command).

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Scriptlets now stop on command failures; fixed by snapcore/snapcraft PR #1545 in commit 3a18cc87a.
stealth/space-bunny-alpha — closed resolved Scriptlets now fail when any command exits nonzero. Fixed by merged snapcore/snapcraft#1545 in commit 3a18cc87a.
stealth/space-bunny-alpha — closed stale Closed without implementation after prolonged inactivity; Launchpad bug 1707189 notes no follow-up, and no resolving PR or commit was identified.
qwen/qwen3.6-35b-a3b — — Closed without implementation. The proposal to enforce the -e shell flag for snapcraft scriptlets to halt on errors was abandoned due to zero discussion or follow-up.
qwen/qwen3.6-35b-a3b — — The request to run scriptlets with the -e shell flag was closed without discussion or resolution, remaining abandoned due to prolonged inactivity.

Update history

Date Change
created

Related work

  • Likely Fixed By: snapcore/snapcraft#1545 (confidence 99%)

    The linked implementation landed as commit 3a18cc87a, titled "pluginhandler: error out on scriptlet errors".

Related issues

Issue Project State Summary Similarity
#1466 scriptlets erroring behavior snapcraft closed Fixed in snapcraft#1545 (commit 3a18cc87a): scriptlets now fail on any command error, not only the final command.
78%