yudai/gotty · error

Error: No command given.

Error message

Error: No command given.

What it means

The CLI app's default Action requires at least one positional argument: the command to run inside the PTY (e.g. bash). If no args are given, it prints the help text and exits with status 1 and this message. GoTTY has no default command, so one must always be supplied.

Source

Thrown at main.go:56

	if err != nil {
		exit(err, 3)
	}

	app.Flags = append(
		cliFlags,
		cli.StringFlag{
			Name:   "config",
			Value:  "~/.gotty",
			Usage:  "Config file path",
			EnvVar: "GOTTY_CONFIG",
		},
	)

	app.Action = func(c *cli.Context) {
		if len(c.Args()) == 0 {
			msg := "Error: No command given."
			cli.ShowAppHelp(c)
			exit(fmt.Errorf(msg), 1)
		}

		configFile := c.String("config")
		_, err := os.Stat(homedir.Expand(configFile))
		if configFile != "~/.gotty" || !os.IsNotExist(err) {
			if err := utils.ApplyConfigFile(configFile, appOptions, backendOptions); err != nil {
				exit(err, 2)
			}
		}

		utils.ApplyFlags(cliFlags, flagMappings, c, appOptions, backendOptions)

		appOptions.EnableBasicAuth = c.IsSet("credential")
		appOptions.EnableTLSClientAuth = c.IsSet("tls-ca-crt")

		err = appOptions.Validate()
		if err != nil {
			exit(err, 6)

View on GitHub (pinned to a080c85cbc)

Solutions

  1. Pass a command as the final positional argument: gotty -w bash
  2. If the command is built from a variable, verify it is non-empty before invoking
  3. Reorder flags so they precede the command argument

Example fix

// before
gotty --port 8080
// after
gotty --port 8080 bash
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$GOTTY_CMD" ]; then echo "usage: gotty [options] <command>" >&2; exit 1; fi
gotty --port 8080 "$GOTTY_CMD"

Try / catch

gotty --port 8080 bash || exit $?  # nonzero exit with 'Error: No command given.' if arg missing

Prevention

When it happens

Trigger: Running `gotty` (or `gotty --port 8080`) with no command argument after options.

Common situations: Putting options after the intended command or forgetting the command entirely; scripts invoking gotty with an empty command variable.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02). Data as JSON: /api/errors/5235df717ba4aefb. Report an issue: GitHub.