cli/cli · error

not logged in to %s account %s

Error message

not logged in to %s account %s

What it means

Error "not logged in to %s account %s" thrown in cli/cli.

Source

Thrown at pkg/cmd/auth/switch/switch.go:100

	if err != nil {
		return err
	}
	authCfg := cfg.Authentication()

	knownHosts := authCfg.Hosts()
	if len(knownHosts) == 0 {
		return fmt.Errorf("not logged in to any hosts")
	}

	if hostname != "" {
		if !slices.Contains(knownHosts, hostname) {
			return fmt.Errorf("not logged in to %s", hostname)
		}

		if username != "" {
			knownUsers := cfg.Authentication().UsersForHost(hostname)
			if !slices.Contains(knownUsers, username) {
				return fmt.Errorf("not logged in to %s account %s", hostname, username)
			}
		}
	}

	var candidates candidates

	for _, host := range knownHosts {
		if hostname != "" && host != hostname {
			continue
		}
		hostActiveUser, err := authCfg.ActiveUser(host)
		if err != nil {
			return err
		}
		knownUsers := cfg.Authentication().UsersForHost(host)
		for _, user := range knownUsers {
			if username != "" && user != username {
				continue

View on GitHub (pinned to 0eeec0b92e)

Solutions

  1. Log in as that account with `gh auth login`, or pick one of the accounts shown by `gh auth status`.

When it happens

Trigger: Thrown at pkg/cmd/auth/switch/switch.go:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15). Data as JSON: /api/errors/0dfdb1d4917a34d7. Report an issue: GitHub.