mislav/hub · error

Unknown config %s

Error message

Unknown config %s

What it means

ConfigAll runs `git config --get-regexp <name>` (or `--get-all`) and returns the output lines. This error is returned whenever the underlying `git config` command exits non-zero, which the library interprets as 'the requested config key has no value or the git command failed'. It wraps the raw git exit status into a single error carrying only the config key name, discarding stderr details.

Source

Thrown at git/git.go:262

	remoteCmd.Stderr = nil
	output, err := remoteCmd.Output()
	return outputLines(output), err
}

func Config(name string) (string, error) {
	return gitGetConfig(name)
}

func ConfigAll(name string) ([]string, error) {
	mode := "--get-all"
	if strings.Contains(name, "*") {
		mode = "--get-regexp"
	}

	configCmd := gitCmd(gitConfigCommand([]string{mode, name})...)
	output, err := configCmd.Output()
	if err != nil {
		return nil, fmt.Errorf("Unknown config %s", name)
	}
	return outputLines(output), nil
}

func GlobalConfig(name string) (string, error) {
	return gitGetConfig("--global", name)
}

func SetGlobalConfig(name, value string) error {
	_, err := gitConfig("--global", name, value)
	return err
}

func gitGetConfig(args ...string) (string, error) {
	configCmd := gitCmd(gitConfigCommand(args)...)
	output, err := configCmd.Output()
	if err != nil {
		return "", fmt.Errorf("Unknown config %s", args[len(args)-1])

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Set the config key first: `git config --global <name> <value>` (e.g. git config --global github.user yourlogin).
  2. Verify the key name/spelling; --get-regexp takes a pattern, so confirm the pattern matches existing keys via `git config --get-regexp <pattern>` manually.
  3. Check that git is installed and the environment (HOME, XDG_CONFIG_HOME) allows reading user/system config.
  4. In code, treat this error as 'unset' and fall back to a default or prompt the user instead of failing.

Example fix

// before
val, err := git.ConfigAll("github.user")
if err != nil { return err }
// after
val, err := git.ConfigAll("github.user")
if err != nil {
    val = nil // treat as unset, use default or prompt
}
Defensive patterns

Strategy: fallback

Validate before calling

if err := exec.Command("git", "config", "--get-regexp", "github.user").Run(); err != nil {
    // key unset — use default before calling ConfigAll
}

Try / catch

val, err := git.ConfigAll("github.user")
if err != nil {
    log.Printf("config github.user unset, using default")
    val = defaultVal
}

Prevention

When it happens

Trigger: Calling ConfigAll(name) where no config entries match the pattern, or where git itself fails (bad gitConfigCommand arguments, missing git binary config, permission errors on config files). Any non-zero exit from configCmd.Output() produces it.

Common situations: Reading an org or per-host setting that was never set (e.g. `github.user`, `hub.host`) before first run; typos in the config key; querying git config in a environment with no HOME set so the global config can't be read; running sync or knownGitHubHosts in CI with a bare/minimal git installation.

Related errors


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