charmbracelet/glow · error

'%s' is not a supported configuration type: use '%s' or '%s'

Error message

'%s' is not a supported configuration type: use '%s' or '%s'

What it means

ensureConfigFile enforces that the configuration filename ends in .yaml or .yml, rejecting anything else via path.Ext. The check applies to the --config value when passed, otherwise to Viper's ConfigFileUsed(). Glow deliberately restricts Viper's broader format support to YAML for its config.

Source

Thrown at config_cmd.go:65

		if err := c.Run(); err != nil {
			return fmt.Errorf("unable to run command: %w", err)
		}

		fmt.Println("Wrote config file to:", configFile)
		return nil
	},
}

func ensureConfigFile() error {
	if configFile == "" {
		configFile = viper.GetViper().ConfigFileUsed()
		if err := os.MkdirAll(filepath.Dir(configFile), 0o755); err != nil { //nolint:gosec
			return fmt.Errorf("could not write configuration file: %w", err)
		}
	}

	if ext := path.Ext(configFile); ext != ".yaml" && ext != ".yml" {
		return fmt.Errorf("'%s' is not a supported configuration type: use '%s' or '%s'", ext, ".yaml", ".yml")
	}

	if _, err := os.Stat(configFile); errors.Is(err, fs.ErrNotExist) {
		// File doesn't exist yet, create all necessary directories and
		// write the default config file
		if err := os.MkdirAll(filepath.Dir(configFile), 0o700); err != nil {
			return fmt.Errorf("unable create directory: %w", err)
		}

		f, err := os.Create(configFile)
		if err != nil {
			return fmt.Errorf("unable to create config file: %w", err)
		}
		defer func() { _ = f.Close() }()

		if _, err := f.WriteString(defaultConfig); err != nil {
			return fmt.Errorf("unable to write config file: %w", err)
		}

View on GitHub (pinned to e3970c813d)

Solutions

  1. Rename the file to end in .yml or .yaml
  2. If you wanted JSON/TOML config, convert it to YAML — glow only accepts YAML
  3. Check for stray suffixes: glow.yml.example must become glow.yml

Example fix

# before
$ glow config --config ~/.config/glow/glow.json
# Error: '.json' is not a supported configuration type: use '.yaml' or '.yml'

# after
$ mv ~/.config/glow/glow.json ~/.config/glow/glow.yml && glow config --config ~/.config/glow/glow.yml
Defensive patterns

Strategy: validation

Validate before calling

func validConfigExt(p string) error {
	ext := path.Ext(p)
	if ext != ".yaml" && ext != ".yml" {
		return fmt.Errorf("%s: glow config must end in .yaml or .yml", p)
	}
	return nil
}

if err := validConfigExt(cfgPath); err != nil {
	cfgPath = strings.TrimSuffix(cfgPath, path.Ext(cfgPath)) + ".yml"
}

Try / catch

if err := ensureConfigFile(); err != nil {
	var extErr *unsupportedConfigTypeError // wrap it in your own sentinel if vendoring
	if errors.As(err, &extErr) || strings.Contains(err.Error(), "not a supported configuration type") {
		// rename to .yml and retry once
		_ = os.Rename(badPath, strings.TrimSuffix(badPath, path.Ext(badPath))+".yml")
		return ensureConfigFile()
	}
	return err
}

Prevention

When it happens

Trigger: Passing glow config --config settings.json (or .toml, .txt, or no extension); a config file discovered by Viper with a non-YAML extension; a typo like glow.yam or config.yaml.bak.

Common situations: Users migrating configs from tools that use JSON/TOML; backup files with extra suffixes; scripts generating the config path with a wrong template.

Related errors


AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15). Data as JSON: /api/errors/0762a76d29460892. Report an issue: GitHub.