junegunn/fzf · error
at least one of 'file' or 'dir' should be specified
Error message
at least one of 'file' or 'dir' should be specified
What it means
Thrown while parsing the --walker option. The walker option list must explicitly include 'file' and/or 'dir' to tell fzf which entry types to emit; every other token (hidden, follow, or skip patterns) only refines the traversal. If neither 'file' nor 'dir' appears, the parsed walkerOpts has both flags false and options parsing aborts.
Solutions
- Include 'file' or 'dir' explicitly: `--walker file,dir,hidden,follow`
- Check spelling of every token: singular 'file'/'dir', not 'files'/'dirs'
- Remove --walker entirely if the default file+dir walking is acceptable
Example fix
# before fzf --walker hidden # after fzf --walker file,dir,hidden
Defensive patterns
Strategy: validation
Validate before calling
# bash: require file or dir token in --walker
walker_ok() {
case ",$1," in
*,file,*|*,dir,*) return 0;;
*) echo "--walker needs 'file' or 'dir'" >&2; return 1;;
esac
}
walker_ok "$WALKER" && fzf --walker "$WALKER" Prevention
- Always write --walker specs starting from file,dir then add modifiers
- Validate generated option strings in CI by running `fzf <opts> </dev/null` and checking the exit status
When it happens
Trigger: Passing --walker with only modifier tokens, e.g. `--walker hidden`, `--walker follow`, `--walker skip:node_modules`, or `--walker hidden,follow` — none of which contains 'file' or 'dir'.
Common situations: A developer adds --walker hidden expecting 'hidden files in addition to defaults', not knowing that file/dir selection is opt-in and not defaulted; or a typo like 'files' or 'dirs' (plural) silently falls through to the invalid-walker-option/default path.
Related errors
- no directory specified
- bind action not specified
- history max must be a positive integer
- invalid info style (expected…
- invalid layout (expected: default / reverse / reverse-list)
AI-assisted analysis of junegunn/fzf@bd4efa277b (2026-08-15).
Data as JSON: /api/errors/192d3b541744af99.
Report an issue: GitHub.
Appendix: source
Thrown at src/options.go:1649
opts := walkerOpts{}
for _, str := range strings.Split(strings.ToLower(str), ",") {
switch str {
case "file":
opts.file = true
case "dir":
opts.dir = true
case "hidden":
opts.hidden = true
case "follow":
opts.follow = true
case "":
// Ignored
default:
return opts, errors.New("invalid walker option: " + str)
}
}
if !opts.file && !opts.dir {
return opts, errors.New("at least one of 'file' or 'dir' should be specified")
}
return opts, nil
}
var (
argActionRegexp *regexp.Regexp
splitRegexp *regexp.Regexp
actionNameRegexp *regexp.Regexp
)
func firstKey(keymap map[tui.Event]string) tui.Event {
for k := range keymap {
return k
}
return tui.EventType(0).AsEvent()
}
const (View on GitHub (pinned to bd4efa277b)