{"record":{"id":"11f15cd86d8f9512","repo":"charmbracelet/gum","slug":"unable-to-create-renderer-w","errorCode":null,"errorMessage":"unable to create renderer: %w","messagePattern":"unable to create renderer: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"format/formats.go","lineNumber":19,"sourceCode":"//nolint\npackage format\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\ttpl \"text/template\"\n\n\t\"charm.land/glamour/v2\"\n\t\"charm.land/lipgloss/v2\"\n)\n\nfunc code(input, language string) (string, error) {\n\trenderer, err := glamour.NewTermRenderer(\n\t\tglamour.WithEnvironmentConfig(),\n\t\tglamour.WithWordWrap(0),\n\t)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to create renderer: %w\", err)\n\t}\n\toutput, err := renderer.Render(fmt.Sprintf(\"```%s\\n%s\\n```\", language, input))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to render: %w\", err)\n\t}\n\treturn output, nil\n}\n\nfunc emoji(input string) (string, error) {\n\trenderer, err := glamour.NewTermRenderer(\n\t\tglamour.WithEmoji(),\n\t)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to create renderer: %w\", err)\n\t}\n\toutput, err := renderer.Render(input)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to render: %w\", err)","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/format/formats.go#L1-L37","documentation":"gum format's `code` handler builds a glamour (markdown terminal renderer) with environment-driven styling (`WithEnvironmentConfig`) and word wrap 0. If `glamour.NewTermRenderer` fails, the error is wrapped as `unable to create renderer: %w`. Failure here means glamour could not construct its renderer, typically due to bad style configuration discovered at construction time.","triggerScenarios":"A `GLAMOUR_STYLE` environment variable names a style that cannot be loaded (unknown name, unreadable/invalid JSON style file), or glamour's style parsing returns an error during NewTermRenderer.","commonSituations":"Users setting GLAMOUR_STYLE to a custom JSON file with schema errors; typos like `GLAMOUR_STYLE=darkk`; environments where the default style definitions are missing from the installed version.","solutions":["Unset `GLAMOUR_STYLE` or set it to a valid built-in: ascii, dark, light, pink, DRACULA, NO_COLOR, or a valid JSON style path.","Validate the custom style JSON against glamour's Style schema (ansi style spec).","Fix file permissions on the referenced style file.","Upgrade gum/glamour if the configured style name was removed in a newer version."],"exampleFix":"// before\nexport GLAMOUR_STYLE=darkk // invalid style name\n gum format -t code file.go // unable to create renderer\n// after\nexport GLAMOUR_STYLE=dark\n gum format -t code file.go","handlingStrategy":"validation","validationCode":"if [ -n \"$GLAMOUR_STYLE\" ]; then\n  case \"$GLAMOUR_STYLE\" in\n    ascii|dark|light|pink|dracula|DRACULA|notty|NO_COLOR) ;;\n    *) [ -r \"$GLAMOUR_STYLE\" ] || { echo \"invalid GLAMOUR_STYLE: $GLAMOUR_STYLE\" >&2; unset GLAMOUR_STYLE; } ;;\n  esac\nfi","typeGuard":null,"tryCatchPattern":"if ! out=$(gum format -t code \"$src\"); then\n  echo \"renderer creation failed: $out — check GLAMOUR_STYLE\" >&2\n  unset GLAMOUR_STYLE\n  out=$(gum format -t code \"$src\")\nfi","preventionTips":["Only set GLAMOUR_STYLE to built-ins (ascii/dark/light/pink/DRACULA/notty) or validated JSON files.","Validate custom style JSON against glamour's schema before use.","Unset GLAMOUR_STYLE in CI to guarantee default behavior.","Test gum format after any style/environment changes."],"tags":["go","cli","glamour","configuration"],"backgroundTag":"invalid-style-config","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}