charmbracelet/glow · error
unable to parse PAGER command: %s
Error message
unable to parse PAGER command: %s
What it means
When output goes through a pager (pager true or --pager changed), glow reads PAGER (defaulting to "less -r") and tokenizes it with shell.Fields from mvdan.cc/sh/v3 - a POSIX-style field splitter that honors quotes and variable expansion. This error means tokenization failed or produced no fields: the PAGER value is not a syntactically valid shell command line. The message includes the raw PAGER string so you can see what failed to parse.
Source
Thrown at main.go:324
content = utils.WrapCodeBlock(string(b), ext)
}
out, err := r.Render(content)
if err != nil {
return fmt.Errorf("unable to render markdown: %w", err)
}
// display
switch {
case pager || cmd.Flags().Changed("pager"):
pagerCmd := os.Getenv("PAGER")
if pagerCmd == "" {
pagerCmd = "less -r"
}
fields, err := shell.Fields(pagerCmd, os.Getenv)
if err != nil || len(fields) == 0 {
return fmt.Errorf("unable to parse PAGER command: %s", pagerCmd)
}
c := exec.Command(fields[0], fields[1:]...) //nolint:gosec
c.Stdin = strings.NewReader(out)
c.Stdout = os.Stdout
if err := c.Run(); err != nil {
return fmt.Errorf("unable to run command: %w", err)
}
return nil
case tui || cmd.Flags().Changed("tui"):
path := ""
if !isURL(src.URL) {
path = src.URL
}
return runTUI(path, content)
default:
if _, err = fmt.Fprint(w, out); err != nil {
return fmt.Errorf("unable to write to writer: %w", err)
}View on GitHub (pinned to e3970c813d)
Solutions
- Check PAGER for unbalanced quotes or stray characters: echo "$PAGER"
- Set a simple known-good value: export PAGER='less -r'
- Temporarily unset PAGER (unset PAGER) to confirm it is the cause
- Use straight ASCII quotes, not typographic ones, in shell configs
Example fix
# before export PAGER='less -r" # unbalanced quote # after export PAGER='less -r'
Defensive patterns
Strategy: validation
Validate before calling
func pagerParses(pagerCmd string) bool {
fields, err := shell.Fields(pagerCmd, os.Getenv)
return err == nil && len(fields) > 0
} Prevention
- Validate PAGER with shell.Fields before using it
- Keep PAGER simple and single-quoted: export PAGER='less -r'
- Avoid typographic quotes in shell configs
When it happens
Trigger: Unbalanced quotes in PAGER (PAGER='less -r"), stray backslashes, or expansion errors inside the PAGER string; a PAGER that expands to an empty command line.
Common situations: User shell configs exporting PAGER with quoting mistakes, values copied from tutorials with smart/curly quotes, templates injecting broken quoting into PAGER.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unable to set config file: %w
- unable to run command: %w
- error parsing config: %v
- cannot use both pager and tui
- unable to run command: %w
AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15).
Data as JSON: /api/errors/deef51fb7cd773ff.
Report an issue: GitHub.