{"record":{"id":"419843c93b416dc7","repo":"charmbracelet/gum","slug":"no-file-selected","errorCode":null,"errorMessage":"no file selected","messagePattern":"no file selected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"file/command.go","lineNumber":74,"sourceCode":"\t\tkeymap:      defaultKeymap(),\n\t\theaderStyle: o.HeaderStyle.ToLipgloss(),\n\t\theader:      o.Header,\n\t}\n\n\tctx, cancel := timeout.Context(o.Timeout)\n\tdefer cancel()\n\n\ttm, err := tea.NewProgram(\n\t\tm,\n\t\ttea.WithOutput(os.Stderr),\n\t\ttea.WithContext(ctx),\n\t).Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to pick selection: %w\", err)\n\t}\n\tm = tm.(model)\n\tif m.selectedPath == \"\" {\n\t\treturn errors.New(\"no file selected\")\n\t}\n\n\tfmt.Println(m.selectedPath)\n\treturn nil\n}\n","sourceCodeStart":56,"sourceCodeEnd":80,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/file/command.go#L56-L80","documentation":"After the file picker's bubbletea program finishes, Run checks m.selectedPath; an empty value means the program ended without a chosen path (user aborted the picker). Run surfaces this instead of printing an empty path.","triggerScenarios":"tea.Program.Run() succeeds but the model's selectedPath is empty — the user exited the filepicker without choosing a file/directory (esc/ctrl-c/q).","commonSituations":"Users cancelling out of the picker; scripts assuming a file is always chosen; permission-restricted directories where nothing can be selected and the user quits.","solutions":["Treat the non-zero exit as 'user cancelled' and handle it in your script","Start the picker in a directory the user can navigate and select from (check permissions)","Provide an explicit fallback path when the user cancels"],"exampleFix":"// before\npath=$(gum file --file) || exit 1\n// after\npath=$(gum file --file) || { echo \"cancelled\"; exit 0; }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"if ! path=$(gum file --file); then\n  echo 'no file chosen (user cancelled)'\n  exit 0\nfi","preventionTips":["Check exit status after gum file","Start the picker in a readable, navigable directory","Provide a fallback path for cancellations"],"tags":["cli","gum","file","user-cancelled"],"backgroundTag":"user-aborted-selection","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}