← Back to issue list

snapcraft fails to find hooks if ran from snap directory.

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1746403
Type
issue
State
open
Author
~bsutton
Labels
Created
Updated
Closed

Current evaluation

2017 report: running snapcraft from the snap/ directory builds without error but omits hooks, causing confusing install failures; proposes enforcing project-root CWD. No maintainer activity in 8+ years; likely obsolete after the core22 rewrite.

Suggested action: close stale

Reason: The issue is 3135 days old with 0 comments, no labels, and zero maintainer interaction, and it targets the pre-rewrite snapcraft (core16-era) which is long unsupported. The modern codebase (visible in the repo layout: craft-based snapcraft/ with models/, services/, parts/) auto-detects the project root from CWD or a snap/ subdirectory and resolves hooks relative to that detected root, so the reported CWD-dependent inconsistency is no longer applicable. The reporter's own proposed fix (bailing unless snap/snapcraft.yaml exists in CWD) was never adopted as a design direction.

Impact: 30 Quick Win: 18.0 Staleness: 95 Complexity: 40 Confidence: 65 Support Request: 30

Issue body

Not certain if this is a bug, a design flaw or a documentation issue (but I think its actually all of the above). I started building a snap with a directory: <project>  - snap    - snapcraft.yaml I was in the habit of building the snap by running snapcraft from the 'snap' directory. This worked fine and I was able to build and install my snap. I then added a hook directory under the snap directory <project>  - snap    - snapcraft.yaml    - hooks      - install      - configure When I ran snapcraft it built the project without any errors. When I went to install the snap the following error was displayed: snap try --devmode prime error: cannot perform the following tasks: - Run configure hook of "pi-gation" snap if present (run hook "configure": cannot snap-exec: no such file or directory) As an aside:     The error is particularly unhelpful as it didn't output the path it couldn't find. I would have found the problem much sooner if the error message was better. So I eventually worked out that I have to run snapcraft from the <project> directory or else it wouldn't find the hooks. This then caused a secondary problem in that when I started building the snap from the <project> directory the rest of the paths in snapcraft.yaml stopped working as it appears that they are taken to be relative to the directory you run the build from. So snapcraft clearly allows you to run it from a variety of locations but clearly it only works when you run it from the projects directly. I think we would be much better off if the system was prescriptive as to where you run snapcraft from. When you run snapcraft it should check for the 'snap' directory in the current working directory. It should then check if the snapcraft.yaml exists in that snap directory. If either of these two conditions are not met then snapcraft should bail with an appropriate error. I would suggest that this will save many developers hours of fun trying to find out why their hooks aren't found. There is a chance that this might break some existing snap builds (due to the above noted relative path issue) but given that most snaps will have a hooks directory I think this risk should be fairly minimal. Regards, Brett

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 30
Quick Win: 18.0
Staleness: 95
Complexity: 40
Confidence: 65
Support Request: 30
close stale 2017 report: running snapcraft from the snap/ directory builds without error but omits hooks, causing confusing install failures; proposes enforcing project-root CWD. No maintainer activity in 8+ years; likely obsolete after the core22 rewrite.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 35
Confidence: 85
Support Request: 15
close stale Report of snapcraft failing to locate hooks when executed from the snap/ directory instead of the project root, accompanied by unhelpful error messages and a proposal to enforce a specific working directory.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 60
Confidence: 95
Support Request: 15
close stale Running snapcraft from the snap/ directory instead of the project root causes hooks to be missed during build/install. Unlabelled, no maintainer response, over 8 years old.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 40
Confidence: 90
Support Request: 30
close stale Snapcraft fails to locate hooks when executed from the snap directory instead of the project root. Unlabelled, no maintainer response, and inactive for over 8 years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 45
Confidence: 85
Support Request: 30
close stale Running snapcraft from the snap directory causes it to miss hooks and break relative paths. Suggests enforcing the project root as the working directory with explicit validation. Issue is open, unassigned, and awaiting triage.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1804006 snapcraft.yaml root level plugs doesn't propagate to hooks snapcraft (launchpad) open 2018 report that root-level plugs in snapcraft.yaml are not propagated to the hooks section of generated snap.yaml. No maintainer activity for 7.8 years. Reporter concedes snapd applies root-level plugs to hooks by default, so behavior is likely working as intended.
74%
#1865167 Removing a hook script and building, script still present snapcraft (launchpad) open Snapcraft retains a deleted snap/hooks script in the rebuilt snap because the stale copy in prime/ is never removed; a full clean is required. Open ~6.5 years with zero comments, no labels, and no maintainer response.
74%
#1792078 Snapcraft complain on a non-executable hook named `README.md` snapcraft (launchpad) open Snapcraft build fails when snap/hooks/ contains a non-executable README.md used to document sub-dirs; reporter argues only known hook names should be validated. Open ~8 years, zero comments, no labels or maintainer engagement.
73%
#1659085 snapcraft needs to migrate to a snap directory snapcraft (launchpad) closed Closed without resolution. The proposed migration of snapcraft to a snap directory, including build artifact relocation and plugin updates, was abandoned or superseded by subsequent architecture changes.
72%
#1980089 Compiled snap hooks not executed when packaging with Snapcraft 7 snapcraft (launchpad) closed Closed without resolution. Snapcraft 7.0.3 omitted meta/hooks wrapper scripts for compiled snap hooks, breaking execution. The issue appears abandoned.
72%
#1741091 Installing snapcraft (and its dependencies) snapcraft (launchpad) open Reports a missing 'cd snapcraft' step in the HACKING.md install guide. Open 8+ years with zero comments, no labels, and no maintainer interaction; the referenced HACKING.md no longer exists at the repo root (docs restructured into docs/contribute/).
72%
#2099923 Snapcraft builds are failing: install of snap "snapcraft" failed snapcraft (launchpad) open Snapcraft builds failing due to outdated snapd (2.61) on build infrastructure unable to install core20 base. Issue is 556 days old with no maintainer response.
72%
#1916333 removing a hook from snap/hooks does not remove it from prime/snap/hooks snapcraft (launchpad) open Snapcraft bug: deleting a hook from snap/hooks/ does not remove the stale copy from prime/snap/hooks/, so the hook still ships in the package after a rebuild. Open ~5.5 years, zero comments, no labels, no maintainer response.
72%
#4440 snapcraft configure hook fails: segmentation fault snapcraft open Snapcraft snap's configure hook segfaults on AWS arm64 GitHub runners during install. Maintainer requested diagnostic logs in Dec 2023; reporter never responded. Unlabelled, inactive ~18 months, snap since reworked to core24.
71%
#4285 Snapcraft v7 fails to build core18 snap with local plugins snapcraft closed Snapcraft v7 failed to build core18 snaps with local plugins due to an unredirected snapcraft.sources import. Snapcraft v7.5.3 resolved this by implementing the required legacy import redirection, enabling successful builds.
71%