snapcraft clean fails on a clean directory
Metadata
Current evaluation
Fixed a FileNotFoundError crash in snapcraft clean when executed on a fresh directory. The command now gracefully handles the absence of the parts directory instead of failing.
Suggested action: —
No scores available.
Issue body
$ ./../../bin/snapcraft clean
Starting new HTTPS connection (1): wiki.ubuntu.com
Cleaning up for part 'curl'
Cleaning up for part 'main'
Traceback (most recent call last):
File "./../../bin/snapcraft", line 33, in <module>
snapcraft.main.main()
File "/home/elopio/workspace/canonical/snapcraft/trunk/snapcraft/main.py", line 80, in main
args.func(args)
File "/home/elopio/workspace/canonical/snapcraft/trunk/snapcraft/cmds.py", line 240, in clean
if not os.listdir(common.get_partsdir()):
FileNotFoundError: [Errno 2] No such file or directory: '/home/elopio/workspace/canonical/snapcraft/trunk/examples/downloader-with-wiki-parts/parts'
To reproduce:
bzr branch lp:snapcraft
cd snapcraft/examples/downloader-with-wiki-parts
./../../bin/snapcraft clean
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Fixed a FileNotFoundError crash in snapcraft clean when executed on a fresh directory. The command now gracefully handles the absence of the parts directory instead of failing. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed. The snapcraft clean command crashed with a FileNotFoundError when the parts directory was missing. Resolved by adding a directory existence check before listing contents. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed a FileNotFoundError crash when running snapcraft clean on a fresh directory by safely handling missing parts directories. The issue was closed after the fix was applied. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1717413 snapcraft snap with an unexisting dir shows a traceback | snapcraft (launchpad) | closed | Fixed by implementing proper error handling for missing directories. The Python traceback was replaced with a clear SnapcraftEnvironmentError, providing users with a concise message to verify the directory path before running snapcraft. | |
| #1690139 "snapcraft clean <part>" fails if the files I asked it to clean don't exist | snapcraft (launchpad) | closed | Closed. The snapcraft clean <part> FileNotFoundError for missing artifacts was fixed by adding graceful error handling to skip non-existent files during cleanup. | |
| #1601 snapcraft.yaml: don't re-use build dir | snapcraft | merged | Merged a fix for a source-build directory clash in snapcraft.yaml. The build directory was renamed to apt-build to avoid scriptlet conflicts. Approved by reviewers and passed CI, resolving the failure. | |
| #1591056 snapcraft clean <part> doesn't remove the bin/ directory | snapcraft (launchpad) | closed | The bug where snapcraft clean <part> leaves the bin/ directory behind was abandoned and closed without resolution. No fix was implemented or merged, likely due to prolonged inactivity. | |
| #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. | |
| #1615060 snapcraft clean is incomplete | snapcraft (launchpad) | closed | Reporting that snapcraft clean skips local .snap files was closed without comments or resolution, indicating the report was abandoned or left unresolved. |