← 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

Running Snapcraft from snap/ can misidentify the assets directory as the project root and omit adjacent hooks; PR #3379 adds a warning, but lookup remains order-based.

Suggested action: keep open

Reason: The report gives an exact layout and failure, and maintainer ~kyrofa confirmed that both manifest locations are valid while proposing directory heuristics. Commit 54162eb95 (#3379) added a warning, but current get_snap_project() still selects the first existing manifest from a fixed list and project_check.py does not make the nested-cwd case safe, so a regression test and a clear fix are still needed.

Evaluated by: mr-cal-bot

Impact: 55 Quick Win: 22 Complexity: 52 Confidence: 86 Actionability: 82

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
stealth/space-bunny-alpha
Impact: 55
Quick Win: 22
Complexity: 52
Confidence: 86
Actionability: 82
keep open Running Snapcraft from snap/ can misidentify the assets directory as the project root and omit adjacent hooks; PR #3379 adds a warning, but lookup remains order-based.
stealth/space-bunny-alpha
Impact: 45
Quick Win: 26
Complexity: 35
Confidence: 89
Actionability: 88
close resolved Snapcraft misdetected <project>/snap as the project root, omitting adjacent hooks; PR #3379 added a warning for builds launched inside an assets directory.
stealth/space-bunny-alpha
Impact: 42
Quick Win: 14
Complexity: 58
Confidence: 95
Actionability: 80
keep open Maintainer-confirmed layout ambiguity remains: running Snapcraft inside snap/ selects the root layout, omits sibling hooks, and produces a snap that fails when installed.
qwen/qwen3.6-35b-a3b
Impact: 40
Quick Win: 12
Complexity: 50
Confidence: 50
Actionability: 60
keep open Snapcraft fails to find hooks when run from the snap/ directory instead of project root. Issue is 9 years old; codebase has significantly refactored since then.
qwen/qwen3.8-27b
Impact: 30
Quick Win: 18
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.

Update history

Date Change
created

Related work

  • Likely Fixed By: snapcraft#3379 (confidence 85%)

    Commit 54162eb95 added a CLI warning for running inside the assets directory, providing diagnostic mitigation but not clear evidence that hook discovery was corrected.

Related issues

Issue Project State Summary Similarity
#3379 cli: warn when running snapcraft inside assets directory snapcraft merged Merged #3379 (commit 54162eb95), adding a CLI warning when Snapcraft runs from snap or build-aux asset directories.
71%