snapcraft help fails on many commands
Metadata
Current evaluation
Fixed by merged PR #5178 (commit f97d032bf), adding missing help text for positional args; maintainer closed the issue noting the fix ships in snapcraft 8.5.1.
Resolution: closed resolved
Reason: PR #5178 'fix: properly present help when posargs have no help' was merged as commit f97d032bf. mr-cal reproduced the crash, traced it to positional arguments declared without a help field in snapcraft/commands/legacy.py, and closed the issue stating 'Fixed in #5178, will be released in snapcraft 8.5.1'.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
On some commands such as promote, validate, revisions... you get error output when trying to do `snapcraft help <command>` or `snapcraft <command> -h`
### To Reproduce
run `snapcraft help <command>` with one of the above mentioned commands, and possibly others.
### Environment
Ubuntu, snapcraft 8.5.0
### snapcraft.yaml
```yaml
n/a
```
### Relevant log output
```shell
Internal error while loading snapcraft: IndexError('list index out of range')
Full execution log: '/home/plars/.local/state/snapcraft/log/snapcraft-20241206-152815.612091.log'
Traceback (most recent call last):
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/application.py", line 502, in _get_dispatcher
global_args = dispatcher.pre_parse_args(sys.argv[1:], app_config)
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 476, in pre_parse_args
help_text = self._get_requested_help(cmd_args, app_config)
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 358, in _get_requested_help
return self._help_builder.get_command_help(command, command_options, output_format)
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/helptexts.py", line 468, in get_command_help
textblocks = builder(command, usage, parameters, options, other_command_names)
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/helptexts.py", line 337, in _build_plain_command_help
positional_args_lines.extend(_build_item_plain(title, text, max_title_len))
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/helptexts.py", line 71, in _build_item_plain
first = f" {title:>{title_space}s}: {wrapped_lines[0]}"
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/application.py", line 663, in run
return_code = self._run_inner()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/application.py", line 202, in _run_inner
return_code = super()._run_inner()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/application.py", line 610, in _run_inner
dispatcher = self._get_dispatcher()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/application.py", line 431, in _get_dispatcher
return super()._get_dispatcher()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/application.py", line 525, in _get_dispatcher
if self.services.config.get("debug"):
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/service_factory.py", line 125, in __getattr__
instance.setup()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/config.py", line 163, in setup
super().setup()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/base.py", line 45, in setup
emit.debug(f"Setting up {self.__class__.__name__}")
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/messages.py", line 417, in func
raise RuntimeError("Emitter is stopped already")
RuntimeError: Emitter is stopped already
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/snap/snapcraft/13008/bin/snapcraft", line 8, in <module>
sys.exit(main())
File "/snap/snapcraft/13008/lib/python3.10/site-packages/snapcraft/application.py", line 482, in main
return app.run()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/application.py", line 693, in run
if self.services.config.get("debug"):
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/service_factory.py", line 125, in __getattr__
instance.setup()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/config.py", line 163, in setup
super().setup()
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_application/services/base.py", line 45, in setup
emit.debug(f"Setting up {self.__class__.__name__}")
File "/snap/snapcraft/13008/lib/python3.10/site-packages/craft_cli/messages.py", line 417, in func
raise RuntimeError("Emitter is stopped already")
RuntimeError: Emitter is stopped already
```
### Additional context
_No response_
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #5178 (commit f97d032bf), adding missing help text for positional args; maintainer closed the issue noting the fix ships in snapcraft 8.5.1. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in merged PR #5178 (f97d032bf) by handling positional arguments without help text; the maintainer said it would ship in Snapcraft 8.5.1. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed a crash in snapcraft help caused by missing help text for certain arguments, triggering an IndexError in craft_cli. Resolved in PR #5178 and released in snapcraft 8.5.1. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in PR #5178 and released in snapcraft 8.5.1. The help command crashed with an IndexError on arguments lacking help text. Adding the missing descriptions resolved the crash. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed a crash in snapcraft help caused by missing help text for certain arguments, triggering an IndexError. Resolved in PR #5178 and released in snapcraft 8.5.1. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/snapcraft#5178
(confidence 99%)
Merged PR that fixes the IndexError in help text rendering for positional args lacking help; merged as commit f97d032bf
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1986645 Some snapcraft 7.x commands have irrelevant "help" info | snapcraft (launchpad) | closed | Fixed in Snapcraft 8 by command-group help refactoring merged in canonical/snapcraft#4934 (commit 6a388877f). | |
| #1699 snapcraft <help> command | snapcraft | closed | Feature request by maintainer sergiusens to add a `snapcraft help <command>` sub-command. Resolved by merged PR #1845, commit cf20b3593 ("cli: implement help <command> (#1845)"), which added command-specific help support. | |
| #1701 snapcraft help” only command summary | snapcraft | closed | Request for concise `snapcraft help` output was closed without implementation or explanation; no resolving PR or commit was recorded. | |
| #1845 cli: implement help <command> | snapcraft | merged | PR #1845 (commit cf20b3593) by sergiusens merged command-specific help support, adding `snapcraft help <command>` to the CLI and closing feature request #1699. | |
| #1789 cli: improve the help command | snapcraft | merged | Merged PR #1789 in commit e66b29d84, giving snapcraft help parity with --help and exposing topic and plugin help; it resolved snapcraft#1698. | |
| #3735 commands: help for all legacy commands | snapcraft | merged | Merged PR #3735, adding help passthrough for all legacy Snapcraft commands; merged as commit 8f8b2df42. | |
| #1834871 snapcraft help doesn't show --shell-before, or --shell, or --destructive-mode options | snapcraft (launchpad) | closed | Closed without a help fix after a maintainer said command-less snapcraft was deprecated. PR #6074 removed that default command, but #6178 reverted the removal, leaving the mismatch unresolved. | |
| #1591011 snapcraft-parser help doesn't explain what the command does | snapcraft (launchpad) | closed | Fixed by snapcore/snapcraft#986 in commit b4e53f81e, which added useful command descriptions to snapcraft-parser help. | |
| #1582506 --help needs some love | snapcraft (launchpad) | closed | Resolved by snapcore/snapcraft#1307 (commit d34dc16af), replacing docopt with Click and adding clearer per-subcommand help and option summaries. | |
| #1698116 snapcraft help claims to have help for topics, but doesn't | snapcraft (launchpad) | closed | Merged PR #1789 in commit e66b29d84 improved `snapcraft help` so its available topics can be discovered. |