← Back to issue list

fix: don't crash if "snap" is a file

View original Github issue

Metadata

Project
snapcraft
Number
#5512
Type
pull request
State
merged
Author
edisile
Labels
Created
Updated
Closed

Current evaluation

Merged fix preventing crashes when the snap directory is replaced by a file. The change raises a ProjectDirectoryTypeError with improved error messaging, resolving issue #5167. Approved by two reviewers and passed CI checks.

Suggested action:

No scores available.

Issue body

- [x] Have you followed the [guidelines for contributing](https://github.com/canonical/snapcraft/blob/main/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [x] Have you successfully run `make lint`? - [x] Have you successfully run `make test`? (some tests are failing on my machine because arm64 is not supported, CI passed all tests) --- This PR solves https://github.com/canonical/snapcraft/issues/5167 It does so by raising a ProjectDirectoryTypeError when the "${PWD}/snap" path is occupied by a file rather than a directory. To improve UX it also adds an error message when attempting to launch any snapcraft command that accesses the "${PWD}/snap" path and its contents

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged fix preventing crashes when the snap directory is replaced by a file. The change raises a ProjectDirectoryTypeError with improved error messaging, resolving issue #5167. Approved by two reviewers and passed CI checks.
qwen3.6-35b-a3b-mtp-q6 Merged. Resolves issue #5167 by raising a ProjectDirectoryTypeError when the snap directory is replaced by a file, preventing crashes and improving error messaging.
qwen3.6-35b-a3b-mtp-q6 Merged fix for issue #5167 preventing crashes when the PWD/snap path is a file. The change raises a ProjectDirectoryTypeError with a descriptive error message to improve UX.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#3971 snap config: do not crash when config cannot be retrieved snapcraft merged Merged. Fixed a crash in get_snap_config() when snapd is unavailable by catching and logging errors. Approved by reviewer and passed CI checks.
71%
#5167 Snapcraft raises an internal error if there is a file called `snap` snapcraft closed Snapcraft crashed with a NotADirectoryError when a file named snap existed in the working directory. The bug was fixed via pull request #5512 and the issue is closed.
71%
#297 Snap: When snapping a directory, look for snap.yaml. snapcraft merged Merged. Resolves Launchpad bug #1541987 by updating directory snapping to locate snap.yaml. The change modifies three files and received maintainer approval.
71%
#1325 cli: proper error for failed snap command snapcraft merged Merged: returns a proper error code when a snap command fails. Approved by one reviewer with no unresolved comments. Changes span two files (+15/-2).
71%