← Back to issue list

'No such file or directory' if application is missing the templates dir

View original Github issue

Metadata

Project
craft-application
Number
#546
Type
issue
State
open
Author
tigarmo
Labels
Created
Updated
Closed

Current evaluation

craft-application init command crashes with unhelpful FileNotFoundError when the application has no templates directory. Maintainers agreed to improve the error message but no PR was created. Bug still present in current code.

Suggested action: keep open

Reason: Maintainers explicitly discussed and agreed on a direction: @lengau suggested making the error message more useful and @mr-cal agreed it was 'a good compromise and a quick improvement.' The bug is still present in the current code (profiles property calls parent_template_dir.iterdir() without checking existence). No PR has been created to implement the agreed-upon fix.

Impact: 25 Quick Win: 21.25 Staleness: 65 Complexity: 15 Confidence: 75 Support Request: 10

Issue body

### Bug Description I have an admittedly dev version of Rockcraft here that is using the new InitCommand but has no templates. ### To Reproduce Run `toolcraft init` where `toolcraft` has no `templates` dir ### part yaml _No response_ ### Relevant log output ```shell ❯ rockcraft init rockcraft internal error: FileNotFoundError(2, 'No such file or directory') Full execution log: '/home/tiago/.local/state/rockcraft/log/rockcraft-20241024-091607.807534.log' Traceback (most recent call last): File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_application/application.py", line 600, in run return_code = self._run_inner() File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_application/application.py", line 550, in _run_inner dispatcher.load_command(self.app_config), File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 246, in load_command self._loaded_command.fill_parser(parser) File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_application/commands/init.py", line 79, in fill_parser choices=self.profiles, File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_application/commands/init.py", line 98, in profiles template_dirs = [ File "/snap/rockcraft/x1/lib/python3.10/site-packages/craft_application/commands/init.py", line 98, in <listcomp> template_dirs = [ File "/snap/rockcraft/x1/usr/lib/python3.10/pathlib.py", line 1017, in iterdir for name in self._accessor.listdir(self): FileNotFoundError: [Errno 2] No such file or directory: '/snap/rockcraft/x1/lib/python3.10/site-packages/rockcraft/templates' ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 25
Quick Win: 21.25
Staleness: 65
Complexity: 15
Confidence: 75
Support Request: 10
keep open craft-application init command crashes with unhelpful FileNotFoundError when the application has no templates directory. Maintainers agreed to improve the error message but no PR was created. Bug still present in current code.
qwen/qwen3.6-35b-a3b
Staleness: 65
Complexity: 20
Confidence: 85
Support Request: 10
keep open Application crashes with FileNotFoundError when templates directory is missing during init command execution. Maintainers discussed improving error messaging instead of fixing the crash.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 75
Support Request: 10
keep open Unhandled FileNotFoundError when running init without a templates directory. Maintainers discussed improving the error message as a compromise but the issue remains open with no recent activity or implementation.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 20
Confidence: 85
Support Request: 10
keep open init command crashes with FileNotFoundError when the templates directory is missing. Maintainers agreed to improve the error message rather than auto-generating templates. Awaiting implementation.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.