{"record":{"id":"df116e7ab43c6b88","repo":"charmbracelet/glow","slug":"unable-to-run-command-w-df116e","errorCode":null,"errorMessage":"unable to run command: %w","messagePattern":"unable to run command: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":330,"sourceCode":"\t}\n\n\t// display\n\tswitch {\n\tcase pager || cmd.Flags().Changed(\"pager\"):\n\t\tpagerCmd := os.Getenv(\"PAGER\")\n\t\tif pagerCmd == \"\" {\n\t\t\tpagerCmd = \"less -r\"\n\t\t}\n\n\t\tfields, err := shell.Fields(pagerCmd, os.Getenv)\n\t\tif err != nil || len(fields) == 0 {\n\t\t\treturn fmt.Errorf(\"unable to parse PAGER command: %s\", pagerCmd)\n\t\t}\n\t\tc := exec.Command(fields[0], fields[1:]...) //nolint:gosec\n\t\tc.Stdin = strings.NewReader(out)\n\t\tc.Stdout = os.Stdout\n\t\tif err := c.Run(); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to run command: %w\", err)\n\t\t}\n\t\treturn nil\n\tcase tui || cmd.Flags().Changed(\"tui\"):\n\t\tpath := \"\"\n\t\tif !isURL(src.URL) {\n\t\t\tpath = src.URL\n\t\t}\n\t\treturn runTUI(path, content)\n\tdefault:\n\t\tif _, err = fmt.Fprint(w, out); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to write to writer: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n}\n\nfunc runTUI(path string, content string) error {\n\t// Read environment to get debugging stuff","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/main.go#L312-L348","documentation":"The tokenized pager command is executed with exec.Command(fields[0], fields[1:]...) and the rendered output piped to its stdin via c.Run(). This error means the command could not start or exited abnormally: the binary is not found or not executable (exec.Error), or the pager was killed by a signal / exited non-zero / its output pipe broke.","triggerScenarios":"PAGER points at a binary that is not installed (improbable-pager, vimpager) or lacks +x; the pager crashes on the content; the pager is killed by a signal; the pager's own stdout is a broken pipe.","commonSituations":"PAGER set to a tool that exists on one machine but not another, pagers crashing on very large output, WSL/remote environments where the configured pager is a Windows-side binary.","solutions":["Verify the pager exists: command -v $PAGER","Test it directly: echo hi | $PAGER","Fall back to a standard pager: PAGER=less glow README.md or unset PAGER","Check the pager's exit behavior - some tools exit non-zero on quit"],"exampleFix":"# before\nexport PAGER='improbable-pager --dark'\n\n# after\nexport PAGER='less -r'","handlingStrategy":"fallback","validationCode":"func pagerRunnable(pagerCmd string) bool {\n\tfields, err := shell.Fields(pagerCmd, os.Getenv)\n\tif err != nil || len(fields) == 0 { return false }\n\t_, err = exec.LookPath(fields[0])\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point PAGER at an installed, simple pager such as less -r","Run exec.LookPath on the pager binary before spawning it","Fall back to writing directly to stdout when the pager fails to start"],"tags":["pager","process","exec","shell"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}