← Back to issue list

install scriptlet fails with stacktrace and failed command in deleted tmp files

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1751749
Type
issue
State
closed
Author
~kalikiana
Labels
stacktrace
Created
Updated
Closed

Current evaluation

Fixed as a side effect of merged snapcore/snapcraft#2002 (commit bbca282fa), which reworked scriptlet command and error handling.

Resolution: closed resolved

Reason: The issue was closed after the fix landed as part of merged snapcore/snapcraft#2002, commit bbca282fa, which reworked scriptlet command and error handling.

Evaluated by: mr-cal-bot

No scores available.

Issue body

When using an "install" scriptlet for example to patch files in a part and the scriptlet fails, Snapcraft exits with an error pointing at non-existing temporary files and a Python stack trace. $ export SNAPCRAFT_CONTAINER_BUILDS=1 $ snapcraft [...] File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 331, in build script_runner.run(scriptlet=self._part_properties.get('install')) File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_scriptlets.py", line 43, in run run([scriptlet_path], cwd=self._builddir) File "/usr/lib/python3/dist-packages/snapcraft/internal/common.py", line 63, in run subprocess.check_call(['/bin/sh', f.name] + cmd, **kwargs) File "/usr/lib/python3.5/subprocess.py", line 581, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/bin/sh', '/tmp/tmp813kk051', '/tmp/tmpgy_w76ph']' returned non-zero exit status 1 ^^ I saw this when building Snapcraft itself in a local container, after having modified the "installs:" scriptlet of the "python" part. But this would happen with any snap involving scriptlets that fail. What actually happens is that the scriptlet is written to a temporary file by ScriptRunner and subprocess.CalledProcessError is not handled. Snapcraft should print the scriptlet that failed to run, ideally with a reference to the part. This also affects prepare and build scriptlets that use the same mechanism.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed as a side effect of merged snapcore/snapcraft#2002 (commit bbca282fa), which reworked scriptlet command and error handling.
stealth/space-bunny-alpha — closed resolved Fixed as a side effect of merged PR snapcore/snapcraft#2002, which reworked scriptlet command and error handling.
stealth/space-bunny-alpha — closed stale Closed with no documented fix or superseding work; the scriptlet failure report about misleading temporary paths in a Python traceback has no recorded resolution.
qwen/qwen3.6-35b-a3b — — Closed without comments or resolution. The scriptlet error handling issue was abandoned, as the unhandled subprocess stacktrace was not addressed and likely superseded by later upstream improvements.
qwen/qwen3.6-35b-a3b — — Closed as abandoned due to inactivity. The unhandled subprocess error causing stack traces when scriptlets fail remains unresolved.
qwen/qwen3.6-35b-a3b — — Abandoned. The unhandled subprocess error causing stack traces on failed scriptlets remains unresolved.
qwen3.6-35b-a3b-mtp-q6 — — Closed without resolution. Failing scriptlets triggered unhandled subprocess errors with stacktraces referencing deleted temporary files. The report was abandoned after eight years with no fix or pull request submitted.

Update history

Date Change
created

Related work

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

    The issue comment explicitly identifies this merged PR as the source of the fix.

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%
#1650968 when there's a syntax error in a scriptlet, it shows the name of the temp file snapcraft (launchpad) closed Snapcraft added contextual error handling for failed scriptlet execution in commit 3a18cc87a, avoiding diagnostics that exposed only the temporary script path.
70%