JanDeDobbeleer/oh-my-posh · info

invalid yaml

Error message

invalid yaml

What it means

The argocd segment parses the Argo CD CLI config file (~/.config/argocd/config or the file from --config/ARGOCD_OPTS). parseConfig first reads the file content; if the file is missing or empty, it returns 'invalid yaml' because there is nothing to unmarshal. The segment then disables itself.

Source

Thrown at src/segments/argocd.go:80

func (a *Argocd) getConfigFromOpts() string {
	// don't exit/panic when encountering invalid flags
	flags := cmdflag.NewFlagSet(os.Args[0], cmdflag.ContinueOnError)
	// ignore other valid and invalid flags
	flags.ParseErrorsAllowlist.UnknownFlags = true
	// only care about config
	flags.String("config", "", "get config from opts")

	opts := a.env.Getenv(argocdOptsEnv)
	_ = flags.Parse(strings.Split(opts, " "))
	return flags.Lookup("config").Value.String()
}

func (a *Argocd) parseConfig(file string) (bool, error) {
	config := a.env.FileContent(file)
	// missing or empty file content
	if config == "" {
		return false, errors.New(argocdInvalidYaml)
	}

	var data ArgocdConfig
	err := yaml.Unmarshal([]byte(config), &data)
	if err != nil {
		log.Error(err)
		return false, errors.New(argocdInvalidYaml)
	}
	a.Name = data.CurrentContext
	for _, context := range data.Contexts {
		if context.Name == a.Name {
			// mandatory fields in yaml
			if context.Server == "" || context.User == "" {
				return false, errors.New(argocdInvalidYaml)
			}
			a.Server = context.Server
			a.User = context.User
			return true, nil

View on GitHub (pinned to 0976794618)

Solutions

  1. Run `argocd login <server>` to generate ~/.config/argocd/config, or create the file manually if that is all you need.
  2. Remove or disable the argocd segment in your theme if you do not use Argo CD on this machine.
  3. If you intend a custom config, verify the path from ARGOCD_OPTS (--config=...) actually exists and is non-empty.

Example fix

# before - no config file
$ ls ~/.config/argocd/config
No such file

# after
$ argocd login argocd.example.com --username me
# creates ~/.config/argocd/config
Defensive patterns

Strategy: validation

Validate before calling

test -s ~/.config/argocd/config && echo "argocd config present" || echo "run 'argocd login' first"

Prevention

When it happens

Trigger: argocd segment Enabled() runs, getConfigPath() resolves to a path that does not exist (never ran `argocd login`), or the file exists but is empty (zero bytes).

Common situations: Argo CD installed but never logged in so no config file was written; ARGOCD_OPTS pointing --config at a nonexistent file; a fresh machine/container without ~/.config/argocd/config.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/15146bd99705212b. Report an issue: GitHub.