Hive
feat(cli): tuist plugin run / plugin test silently prints help instead of executing
GitHub issue · Closed
Description
tuist plugin run and tuist plugin test print the parent tuist plugin help page and exit with code 0 instead of actually running or testing the plugin.
Steps to reproduce
- Create a minimal plugin:
mkdir -p MyPlugin/Sources/MyPlugin
MyPlugin/Package.swift:
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "MyPlugin",
targets: [
.executableTarget(name: "MyPlugin"),
]
)
MyPlugin/Sources/MyPlugin/main.swift:
print("Plugin executed successfully!")
- Run the plugin via tuist:
tuist plugin run --path MyPlugin MyPlugin
- Observe: the
tuist pluginhelp page is printed and the command exits without executing the plugin.
Expected behavior
The plugin should be built and executed, printing Plugin executed successfully!.
Actual behavior
The help page for tuist plugin is printed and the process exits with code 0. The plugin code is never invoked.
Root cause
PluginRunCommand and PluginTestCommand conform to ParsableCommand but declare async func run(). Since ParsableCommand only defines the synchronous func run() throws, the async method never satisfies the protocol requirement. In TrackableCommand.run(), the as? AsyncParsableCommand cast fails, so the default ParsableCommand.run() is called, which throws CleanExit.helpRequest.
The fix is to change both structs to conform to AsyncParsableCommand instead.
Affected files
cli/Sources/TuistKit/Commands/Plugin/PluginRunCommand.swiftcli/Sources/TuistKit/Commands/Plugin/PluginTestCommand.swift
Environment
- Tuist version: broken since 4.169.1 (introduced in commit 9303ffebd4, PR #10040)
- Last working version: 4.169.0
- macOS (any version)
Workaround
Run the plugin’s Swift package directly:
swift run --configuration debug --package-path MyPlugin MyPlugin