Skip to content

Unexpected “Asynchronous subcommand of a synchronous root” #536

Open
@fboundp

Description

@fboundp

When attempting to create an application with a AsyncParsableCommand root and AsyncParsableCommand subcommands, a fatal error is thrown at runtime “Asynchronous subcommand of a synchronous root.”

ArgumentParser version: 1.2.0
Swift version: swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50) Target: arm64-apple-macosx13.0

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

source:

import protocol ArgumentParser.AsyncParsableCommand
import struct ArgumentParser.CommandConfiguration

@main
struct asyncissue: AsyncParsableCommand {
  static var configuration = CommandConfiguration(subcommands: [Cmd1.self])

  struct Cmd1: AsyncParsableCommand {
    mutating func run() async throws {
      print("Hello")
    }
  }
}

Expected behavior

When resulting command is run, help with a subcommand would be displayed.

Actual behavior

ArgumentParser/ParsableCommand.swift:184: Fatal error: 
--------------------------------------------------------------------
Asynchronous subcommand of a synchronous root.

The asynchronous command `Cmd1` is declared as a subcommand of the
synchronous root command `asyncissue`.

With this configuration, your asynchronous `run()` method will not be
called. To fix this issue, change `asyncissue`'s `ParsableCommand`
conformance to `AsyncParsableCommand`.
--------------------------------------------------------------------

zsh: trace trap  swift run

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions