← Back to issue list

[4.0.7] hook environment does not contain snap-specific PATH and LD_LIBRARY_PATH (as it used to)

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1885294
Type
issue
State
closed
Author
~dmitriis
Labels
Created
Updated
Closed

Current evaluation

⚠️ This summary may be outdated — the issue content or evaluation prompts have changed since this evaluation was made.

Closed due to inactivity with zero comments. The snapcraft 4.0.7 regression where hook wrappers no longer export snap-specific PATH and LD_LIBRARY_PATH was not addressed or fixed.

Suggested action:

No scores available.

Issue body

snapcraft used to generate hook wrappers under meta/hooks/<hook-name> which contained #!/bin/sh export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/lib/x86_64-linux-gnu" export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/lib/x86_64-linux-gnu/ceph:$SNAP/zfs-0.6/lib:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH" exec "$SNAP/snap/hooks/install" "$@" https://github.com/snapcore/snapcraft/blob/4.0.7/snapcraft/internal/meta/_snap_packaging.py#L546-L562 https://github.com/snapcore/snapcraft/blob/4.0.7/snapcraft/internal/meta/_snap_packaging.py#L462 However, this is no longer the case which leads to subtle errors. Example (only visible if SNAPD_DEBUG=1 is set for snapd): * the remove hook gets called during the snap removal; * a binary gets executed in the hook which needs a shared library from a snap-specific LD_LIBRARY_PATH; * the hook silently fails without performing the necessary cleanup. Jun 26 13:17:01 node-hagecius snapd[28196]: taskrunner.go:437: DEBUG: Running task 7199 on Do: Run remove hook of "microstack" snap if present Jun 26 13:17:01 node-hagecius snapd[28196]: task.go:337: DEBUG: 2020-06-26T13:17:01Z ERROR ignoring failure in hook "remove": Jun 26 13:17:01 node-hagecius snapd[28196]: ----- ... Jun 26 13:17:01 node-hagecius snapd[28196]: DEBUG: execv(/usr/lib/snapd/snap-exec, /usr/lib/snapd/snap-exec...) Jun 26 13:17:01 node-hagecius snapd[28196]: DEBUG: argv[1] = --hook=remove Jun 26 13:17:01 node-hagecius snapd[28196]: DEBUG: argv[2] = microstack Jun 26 13:17:01 node-hagecius snapd[28196]: DEBUG: umask restored to 022 Jun 26 13:17:01 node-hagecius snapd[28196]: DEBUG: working directory re-interpreted to / Jun 26 13:17:01 node-hagecius snapd[28196]: + /snap/microstack/current/usr/local/bin/ovs-vsctl --if-exists del-br br-ex Jun 26 13:17:01 node-hagecius snapd[28196]: /snap/microstack/current/usr/local/bin/ovs-vsctl: error while loading shared libraries: libunbound.so.8: cannot open shared object file: No such file or directory Jun 26 13:17:01 node-hagecius snapd[28196]: ----- Jun 26 13:17:01 node-hagecius snapd[28196]: taskrunner.go:437: DEBUG: Running task 7200 on Do: Disconnect interfaces of snap "microstack" I understand that there was a design goal to remove wrappers https://forum.snapcraft.io/t/proposal-support-command-chain-in-apps-and-hooks/6112 but this seems like a major breaking change. Could snap.yaml be modified for a generated snap to include PATH and LD_LIBRARY_PATH (seeing how https://github.com/snapcore/snapd/pull/5498 got merged a while ago)?

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Closed due to inactivity with zero comments. The snapcraft 4.0.7 regression where hook wrappers no longer export snap-specific PATH and LD_LIBRARY_PATH was not addressed or fixed.
qwen/qwen3.6-35b-a3b Abandoned due to inactivity. The snapcraft 4.0.7 regression omitting snap-specific PATH and LD_LIBRARY_PATH from hook environments remains unfixed. No patches or workarounds were implemented.
qwen3.6-35b-a3b-mtp-q6 Closed without resolution. The snapcraft 4.0.7 regression omitting snap-specific PATH and LD_LIBRARY_PATH from hook wrappers, causing silent execution failures, was abandoned. No fix or workaround was implemented.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1975498 PATH/LD_LIBRARY_PATH not set in snapcraft 7.0 snapcraft (launchpad) closed Closed as a reported regression in snapcraft 7.0 where PATH and LD_LIBRARY_PATH are unset after dropping the snapcraft-runner wrapper. A manual workaround was provided.
72%