{"record":{"id":"84f3d5dae7890b7d","repo":"charmbracelet/gum","slug":"could-not-render-file-w","errorCode":null,"errorMessage":"could not render file: %w","messagePattern":"could not render file: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"table/command.go","lineNumber":29,"sourceCode":"\t\"charm.land/gum/v2/internal/stdin\"\n\t\"charm.land/gum/v2/internal/timeout\"\n\t\"charm.land/gum/v2/internal/tty\"\n\t\"charm.land/gum/v2/style\"\n\t\"charm.land/lipgloss/v2\"\n\tltable \"charm.land/lipgloss/v2/table\"\n\t\"golang.org/x/text/encoding\"\n\t\"golang.org/x/text/encoding/unicode\"\n\t\"golang.org/x/text/transform\"\n)\n\n// Run provides a shell script interface for rendering tabular data (CSV).\nfunc (o Options) Run() error {\n\tvar input *os.File\n\tif o.File != \"\" {\n\t\tvar err error\n\t\tinput, err = os.Open(o.File)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not render file: %w\", err)\n\t\t}\n\t} else {\n\t\tif stdin.IsEmpty() {\n\t\t\treturn fmt.Errorf(\"no data provided\")\n\t\t}\n\t\tinput = os.Stdin\n\t}\n\tdefer input.Close() //nolint: errcheck\n\n\ttransformer := unicode.BOMOverride(encoding.Nop.NewDecoder())\n\treader := csv.NewReader(transform.NewReader(input, transformer))\n\treader.LazyQuotes = o.LazyQuotes\n\treader.FieldsPerRecord = o.FieldsPerRecord\n\tseparatorRunes := []rune(o.Separator)\n\tif len(separatorRunes) != 1 {\n\t\treturn fmt.Errorf(\"separator must be single character\")\n\t}\n\treader.Comma = separatorRunes[0]","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/table/command.go#L11-L47","documentation":"Gum table wraps the error from os.Open(o.File) with 'could not render file'. It means the CSV file passed with --file could not be opened — typically it doesn't exist, the path is wrong, or permission is denied.","triggerScenarios":"`gum table --file path/to.csv` where the file is missing, misspelled, in a non-readable directory, or path expansion (~, $VAR) was not performed by the shell (quoted).","commonSituations":"Typos in file paths; using '~' inside quotes so it isn't expanded; running with a different working directory than expected; insufficient read permissions.","solutions":["Verify the file exists: ls -l <path>.","Quote/unquote correctly so the shell expands ~ and $VARS: use unquoted ~/data.csv.","Check read permissions on the file and its directories.","Use an absolute path or verify the current working directory.","Pipe data via stdin instead: `cat data.csv | gum table`."],"exampleFix":"// before\ngum table --file \"~/data.csv\"\n// after\ngum table --file ~/data.csv\n# or absolute path\ngum table --file /home/user/data.csv","handlingStrategy":"validation","validationCode":"f=${FILE:-data.csv}\nif [ ! -r \"$f\" ]; then echo \"cannot read $f\" >&2; exit 1; fi\ngum table --file \"$f\"","typeGuard":null,"tryCatchPattern":"if ! gum table --file \"$f\" 2>err.log; then echo \"table failed: $(cat err.log)\" >&2; fi","preventionTips":["Check os.Stat/file readability before invoking","Use absolute paths","Don't quote ~ or $VARS you want the shell to expand","Fall back to stdin piping when the file is unavailable"],"tags":["cli","file-io","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}