{"record":{"id":"fa789d86cfdad138","repo":"charmbracelet/glow","slug":"unable-to-build-man-page-w","errorCode":null,"errorMessage":"unable to build man page: %w","messagePattern":"unable to build man page: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"man_cmd.go","lineNumber":25,"sourceCode":"\tmcobra \"github.com/muesli/mango-cobra\"\n\t\"github.com/muesli/roff\"\n\t\"github.com/spf13/cobra\"\n)\n\nvar manCmd = &cobra.Command{\n\tUse:                   \"man\",\n\tShort:                 \"Generates manpages\",\n\tSilenceUsage:          true,\n\tDisableFlagsInUseLine: true,\n\tHidden:                true,\n\tArgs:                  cobra.NoArgs,\n\tRunE: func(*cobra.Command, []string) error {\n\t\tmanPage, err := mcobra.NewManPage(1, rootCmd)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to instantiate man page: %w\", err)\n\t\t}\n\t\tif _, err := fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument())); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to build man page: %w\", err)\n\t\t}\n\t\treturn nil\n\t},\n}\n","sourceCodeStart":7,"sourceCodeEnd":30,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/man_cmd.go#L7-L30","documentation":"Despite the message, this does not come from manPage.Build() — Build returns a plain string and cannot fail. The wrapped error is from fmt.Fprint(os.Stdout, ...) at man_cmd.go:24: a write failure on standard output. Typical causes are EPIPE (the downstream reader exited early), ENOSPC (redirect target disk full), or EBADF (file descriptor 1 closed).","triggerScenarios":"`glow man | head -n 5` — head exits after the first write, the pipe closes, and the next write returns EPIPE; redirecting to a full filesystem (`glow man > /tmp/glow.1` with no space); running under a supervisor that closed stdout (`glow man >&-`); piping into any consumer that stops reading mid-stream.","commonSituations":"Shell piping while generating docs; CI artifacts on disk-constrained runners; goreleaser-style man page generation scripts; debugging sessions where output is piped to `head`/`grep -m1`.","solutions":["Write to a file instead of a short-lived pipe: `glow man > glow.1`.","Avoid early-exiting pipe consumers; use a pager that reads everything (`glow man | less`) rather than `head`.","If wrapping the command, treat EPIPE as success before failing (see typeGuard/tryCatchPattern).","Check disk space and fd wiring of the environment when the error persists without pipes."],"exampleFix":"# before: pipe closes early -> unable to build man page: ... broken pipe\nglow man | head -n 1\n\n# after: write to a file, or consume the whole stream\nglow man > glow.1\nglow man | less","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isEPIPE(err error) bool {\n\treturn errors.Is(err, syscall.EPIPE)\n}","tryCatchPattern":"if _, err := fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument())); err != nil {\n\tif errors.Is(err, syscall.EPIPE) {\n\t\treturn nil // reader closed the pipe early; output already delivered\n\t}\n\treturn fmt.Errorf(\"unable to build man page: %w\", err)\n}","preventionTips":["Redirect generator output to a file instead of piping (`glow man > glow.1`).","Never pipe bulk generators into early-exiting consumers like `head -n 1` or `grep -m1`.","Ensure the downstream process reads the entire stream before exiting.","In CI, verify free disk space before redirecting man page output."],"tags":["cli","man-pages","epipe","stdout","shell"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}