junegunn/fzf · error
history max must be a positive integer
Error message
history max must be a positive integer
What it means
Thrown by setHistoryMax while parsing --history-size. The history file size limit must be a positive integer (>= 1); zero or negative values are rejected, including the special case of --history-size 0 which some users try to mean 'unlimited' (use a large number instead).
Source
Thrown at src/options.go:2548
var err error
var historyMax int
if opts.History == nil {
historyMax = defaultHistoryMax
} else {
historyMax = opts.History.maxSize
}
setHistory := func(path string) error {
h, e := NewHistory(path, historyMax)
if e != nil {
return e
}
opts.History = h
return nil
}
setHistoryMax := func(max int) error {
historyMax = max
if historyMax < 1 {
return errors.New("history max must be a positive integer")
}
if opts.History != nil {
opts.History.maxSize = historyMax
}
return nil
}
validateJumpLabels := false
clearExitingOpts := func() {
// Last-one-wins strategy
opts.Bash = false
opts.Zsh = false
opts.Fish = false
opts.Nushell = false
opts.Help = false
opts.Version = false
opts.Man = false
}
View on GitHub (pinned to bd4efa277b)
Solutions
- Pass a positive integer: `--history-size 10000`
- If the intent was unlimited history, use a very large size rather than 0
- Clamp script-computed values to at least 1
Example fix
# before fzf --history-size 0 # after fzf --history-size 1000000
Defensive patterns
Strategy: validation
Validate before calling
# bash [[ "$HISTSIZE" =~ ^[1-9][0-9]*$ ]] || HISTSIZE=10000 fzf --history-size "$HISTSIZE"
Type guard
hist_size_ok() { [[ "$1" =~ ^[1-9][0-9]*$ ]]; } Prevention
- 0 does not mean unlimited; use a large positive number
- Clamp computed history sizes to >= 1
When it happens
Trigger: `--history-size 0`, `--history-size -1`, or --history-size fed by a variable that expands empty/non-numeric then defaults to 0 through the next-int path.
Common situations: Trying to disable history trimming with 0; config generators computing history size from an expression that can be 0; passing --history-size before --history or vice versa is fine, but a negative computed value is not.
Related errors
- unknown action: ${spec}
- invalid layout (expected: default / reverse / reverse-list)
- invalid info style (expected: default|right|hidden|inline[-r
- number of items to keep must be a positive integer
- invalid wrap mode: %s (expected: char or word)
AI-assisted analysis of junegunn/fzf@bd4efa277b (2026-08-15).
Data as JSON: /api/errors/92eb5be34eede523.
Report an issue: GitHub.