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
- Rename the file to end in .yml or .yaml
- If you wanted JSON/TOML config, convert it to YAML — glow only accepts YAML
- 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
- Standardize on glow.yml across machines and dotfile repos to avoid extension drift
- Validate the extension in any script that computes the --config path dynamically
- Remember glow intentionally rejects Viper's other formats (json/toml) — convert, do not rename blindly
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
- cannot use both pager and tui
- unable to set config file: %w
- unable to run command: %w
- could not write configuration file: %w
- unable create directory: %w
AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15).
Data as JSON: /api/errors/0762a76d29460892.
Report an issue: GitHub.