snapcraft snap with an unexisting dir shows a traceback
Metadata
Current evaluation
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.
Suggested action: —
No scores available.
Issue body
To reproduce, run:
⟫ snapcraft snap idontexist
Traceback (most recent call last):
File "/snap/snapcraft/501/bin/snapcraft", line 11, in <module>
load_entry_point('snapcraft==2.34', 'console_scripts', 'snapcraft')()
File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/__main__.py", line 19, in <module>
run(prog_name='snapcraft')
File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 132, in snap
project_options, directory=directory, output=output)
File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", line 345, in snap
snap = _snap_data_from_dir(prime_dir)
File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", line 330, in _snap_data_from_dir
with open(os.path.join(directory, 'meta', 'snap.yaml')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/elopio/tmp/idontexist/meta/snap.yaml'
This should show a nicer message.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | 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. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
98
Complexity:
15
Confidence:
90
Support Request:
10
|
close stale | FileNotFoundError traceback when running snapcraft on a non-existent directory. The report is over 8 years old with zero activity, indicating it is no longer relevant to current versions. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
98
Complexity:
15
Confidence:
95
Support Request:
0
|
close stale | Unhandled FileNotFoundError traceback when running snapcraft on a non-existent directory. Requested a user-friendly error message instead. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
98
Complexity:
15
Confidence:
90
Support Request:
10
|
close stale | Reports a Python traceback when running snapcraft on a non-existent directory instead of a user-friendly error. Issue is inactive for nearly 9 years and likely obsolete. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
95
Complexity:
25
Confidence:
90
Support Request:
15
|
close stale | snapcraft snap crashes with a raw Python traceback when given a non-existent directory. Labeled bitesize and ui, but sits unassigned with zero comments and over eight years of inactivity. Requires a user-friendly error handling fix and triage. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #21 snapcraft throws FileExistsError: with very simple Python snap | snapcraft | closed | Fixed in a maintainer branch. The FileExistsError during snapcraft stage was resolved by replacing the traceback with a clear error message indicating that the local source path must be a directory. | |
| #1497371 snapcraft clean fails on a clean directory | snapcraft (launchpad) | closed | 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. | |
| #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. | |
| #1674952 snapcraft tour broken when installed from snap | snapcraft (launchpad) | closed | The snapcraft tour command failed due to a missing directory path when installed via snap. The issue was closed without comments or documented resolution, indicating it was abandoned or fixed in a later release. | |
| #1604385 Trying to snap a directory that doesn't exist prints [Errno 2] | snapcraft (launchpad) | closed | Resolved by replacing the raw Errno 2 traceback with a clear, user-friendly error message when attempting to snap a non-existent directory. The fix was merged and the issue closed. | |
| #1561331 snapping a dir with old snapcraft files shows: File exists: '/home/elopio/workspace/canonical/snapcraft/ex amples/py2-project/snap/meta/gui' | snapcraft (launchpad) | closed | Closed. Snapcraft raised a FileExistsError when processing legacy directories containing snap/meta/gui. The issue was closed, indicating the path conflict was resolved or abandoned. |