charmbracelet/gum · error
file not found: %w
Error message
file not found: %w
What it means
Run converts the starting --path to an absolute path with filepath.Abs; if that fails (rare OS-level errors like excessively long or malformed paths), it is wrapped as 'file not found'. Note it wraps the abs-resolution error rather than an actual filesystem existence check.
Source
Thrown at file/command.go:28
"charm.land/bubbles/v2/help"
tea "charm.land/bubbletea/v2"
"charm.land/gum/v2/internal/timeout"
"charm.land/gum/v2/style"
)
// Run is the interface to picking a file.
func (o Options) Run() error {
if !o.File && !o.Directory {
return errors.New("at least one between --file and --directory must be set")
}
if o.Path == "" {
o.Path = "."
}
path, err := filepath.Abs(o.Path)
if err != nil {
return fmt.Errorf("file not found: %w", err)
}
fp := filepicker.New()
fp.CurrentDirectory = path
fp.Path = path
fp.SetHeight(o.Height)
fp.AutoHeight = o.Height == 0
fp.Cursor = o.Cursor
fp.DirAllowed = o.Directory
fp.FileAllowed = o.File
fp.ShowPermissions = o.Permissions
fp.ShowSize = o.Size
fp.ShowHidden = o.All
fp.Styles = filepicker.DefaultStyles()
fp.Styles.Cursor = o.CursorStyle.ToLipgloss()
fp.Styles.Symlink = o.SymlinkStyle.ToLipgloss()
fp.Styles.Directory = o.DirectoryStyle.ToLipgloss()
fp.Styles.File = o.FileStyle.ToLipgloss()View on GitHub (pinned to 4d089f9550)
Solutions
- Verify the starting directory exists and your shell's cwd is valid (cd to a real directory)
- Pass a simpler/valid --path value
- Check the wrapped cause (%w) for the underlying OS error
Example fix
// before (cd /deleted/dir && gum file --file) # file not found: ... // after cd /valid/dir && gum file --file
Defensive patterns
Strategy: validation
Validate before calling
[ -d "$start_dir" ] && cd "$start_dir" && gum file --file || echo 'invalid starting path'
Type guard
null
Try / catch
null
Prevention
- Confirm the starting directory exists before invoking
- Avoid running from deleted working directories
- Keep path values within OS length limits
When it happens
Trigger: filepath.Abs(o.Path) returns an error inside Options.Run() — typically from os.Getwd failing or a pathological path value.
Common situations: Running from a deleted working directory (cwd removed); extremely long path values; passing NUL or otherwise invalid bytes in the path.
Related errors
- at least one between --file and --directory must be set
- no file selected
- no options provided, see `gum choose --help`
- nothing selected
- invalid option format: %q
AI-assisted analysis of charmbracelet/gum@4d089f9550 (2026-08-31).
Data as JSON: /api/errors/c517594bf517e10c.
Report an issue: GitHub.