No help text for the "help" sub-command when in a directory containing snapcraft.yaml

Bug #2065230 reported by 林博仁(Buo-ren, Lin)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Confirmed
Undecided
Callahan Kovacs

Bug Description

```
$ snapcraft --version
snapcraft 8.2.5

$ snapcraft help help
Usage: snapcraft [options] command [args]...
Try 'snapcraft -h' for help.

Error: command 'help' not found to provide help for
```

I was originally wanna check whether there an option to specify which base snap to provide the help text of the autotools plugin.

Tags: craft-2904
Revision history for this message
林博仁(Buo-ren, Lin) (buo-ren-lin) wrote : Re: No help text for the "help" sub-command when on a specific working directory.

Wait... the help text is indeed implemented, however, the problem can be reproduced on a different working directory!!?

```
brlin@brlin-fw13:~/文件$ snapcraft help help
Usage: snapcraft [options] command [args]...
Try 'snapcraft -h' for help.

Error: command 'help' not found to provide help for

brlin@brlin-fw13:~/文件$ cd nano-snap
brlin@brlin-fw13:~/文件/nano-snap$ snapcraft help help
Usage: snapcraft help [OPTIONS] <topic>

  Obtain help for a certain topic, plugin or command.

  The <topic> can either be a plugin name or one of:

      - topics
      - plugins
      - sources

  Examples:
      snapcraft help topics
      snapcraft help plugins
      snapcraft help sources
      snapcraft help go
      snapcraft help go --base core18
      snapcraft help build

Options:
  --devel Show more details for snapcraft developers
  --base [core18|core20] Show help for specific base
  -h, --help Show this message and exit.
brlin@brlin-fw13:~/文件/nano-snap$ locale
LANG=zh_TW.UTF-8
LANGUAGE=zh_TW:zh
LC_CTYPE="zh_TW.UTF-8"
LC_NUMERIC="zh_TW.UTF-8"
LC_TIME="zh_TW.UTF-8"
LC_COLLATE="zh_TW.UTF-8"
LC_MONETARY="zh_TW.UTF-8"
LC_MESSAGES="zh_TW.UTF-8"
LC_PAPER="zh_TW.UTF-8"
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT="zh_TW.UTF-8"
LC_IDENTIFICATION="zh_TW.UTF-8"
LC_ALL=
```

summary: - No help text for the "help" sub-command
+ No help text for the "help" sub-command when on a specific working
+ directory.
summary: - No help text for the "help" sub-command when on a specific working
- directory.
+ No help text for the "help" sub-command when in a directory containing
+ snapcraft.yaml
Revision history for this message
林博仁(Buo-ren, Lin) (buo-ren-lin) wrote :

It appears that the `snapcraft help help` command will fail/behave differently if a snapcraft yaml file is found:

```
brlin@brlin-fw13:~/文件/not-snap$ ls
brlin@brlin-fw13:~/文件/not-snap$ snapcraft help help
Usage: snapcraft [options] command [args]...
Try 'snapcraft -h' for help.

Error: command 'help' not found to provide help for

brlin@brlin-fw13:~/文件/not-snap$ touch snapcraft.yaml
brlin@brlin-fw13:~/文件/not-snap$ snapcraft help help
Traceback (most recent call last):
  File "/snap/snapcraft/11627/bin/snapcraft", line 8, in <module>
    sys.exit(main())
  File "/snap/snapcraft/11627/lib/python3.10/site-packages/snapcraft/application.py", line 361, in main
    return app.run()
  File "/snap/snapcraft/11627/lib/python3.10/site-packages/craft_application/application.py", line 488, in run
    dispatcher = self._get_dispatcher()
  File "/snap/snapcraft/11627/lib/python3.10/site-packages/snapcraft/application.py", line 184, in _get_dispatcher
    base = yaml_data.get("base")
AttributeError: 'NoneType' object has no attribute 'get'
brlin@brlin-fw13:~/文件/not-snap$ rm snapcraft.yaml
brlin@brlin-fw13:~/文件/not-snap$ snapcraft init
Created 'snap/snapcraft.yaml'.
Go to https://docs.snapcraft.io/the-snapcraft-format/8337 for more information about the snapcraft.yaml format.
brlin@brlin-fw13:~/文件/not-snap$ snapcraft help help
Usage: snapcraft help [OPTIONS] <topic>

  Obtain help for a certain topic, plugin or command.

  The <topic> can either be a plugin name or one of:

      - topics
      - plugins
      - sources

  Examples:
      snapcraft help topics
      snapcraft help plugins
      snapcraft help sources
      snapcraft help go
      snapcraft help go --base core18
      snapcraft help build

Options:
  --devel Show more details for snapcraft developers
  --base [core18|core20] Show help for specific base
  -h, --help Show this message and exit.

```

Revision history for this message
Callahan Kovacs (mr-cal) wrote :

I can confirm this behavior. We probably need to catch for `help` here similar to catching for `version`: https://github.com/canonical/snapcraft/blob/99387d281624421b613c3c9dc6d3627092fef74b/snapcraft/application.py#L206

We may also need to update these to point to the new craft-application commands:
https://github.com/canonical/snapcraft/blob/99387d281624421b613c3c9dc6d3627092fef74b/snapcraft/cli.py#L37

Changed in snapcraft:
assignee: nobody → Callahan Kovacs (mr-cal)
status: New → Confirmed
Revision history for this message
Callahan Kovacs (mr-cal) wrote :

Tracking internally with CRAFT-2904

tags: added: craft-2904
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.