mislav/hub · error

alias can't be empty

Error message

alias can't be empty

What it means

splitAliasCmd splits an alias's command string into words for execution. An empty alias body cannot be split or executed, so the function immediately returns this error, which propagates when gh expands the alias during command dispatch.

Source

Thrown at commands/runner.go:159

		if e == nil {
			args.Command = words[0]
			args.PrependParams(words[1:]...)
		}
	}
}

func isBuiltInHubCommand(command string) bool {
	for hubCommand := range CmdRunner.All() {
		if hubCommand == command {
			return true
		}
	}
	return false
}

func splitAliasCmd(cmd string) ([]string, error) {
	if cmd == "" {
		return nil, fmt.Errorf("alias can't be empty")
	}

	if strings.HasPrefix(cmd, "!") {
		return nil, fmt.Errorf("alias starting with ! can't be split")
	}

	words, err := shellquote.Split(cmd)
	if err != nil {
		return nil, err
	}

	return words, nil
}

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Delete the broken alias: `gh alias delete <name>`.
  2. Re-set it with a real command: `gh alias set <name> 'pr list'`.
  3. Inspect the config file (aliases section) and remove or fix empty entries.

Example fix

// before
gh alias set co ""
// after
gh alias set co "pr checkout"
Defensive patterns

Strategy: validation

Validate before calling

if aliasBody == "" {
    return fmt.Errorf("alias %q is empty; re-set it with: gh alias set <name> <command>", aliasName)
}

Prevention

When it happens

Trigger: A configured alias (in gh config or `gh alias set`) has an empty value, e.g. `gh alias set myalias ""`, and the user then invokes that alias, causing expandAlias -> splitAliasCmd("").

Common situations: Alias created from a shell variable that expanded to nothing; alias value accidentally deleted from the config file; migration/backup of the config lost the alias body.

Related errors


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/3c6a883f2ad7b506. Report an issue: GitHub.