Installation script incompatible with fzf < 0.48.0 (--zsh flag)
Installation script generates incompatible .fzf.zsh for older fzf versions
Problem Description
The fzf installation script generates a .fzf.zsh configuration file that uses source <(fzf --zsh), which is incompatible with older versions of fzf still distributed in Linux package repositories.
Environment
- fzf version: 0.44.1 (debian package)
- OS: Ubuntu Linux
- Shell: zsh 5.9
- Installation method: Git clone + install script
Steps to Reproduce
- Install fzf using the official installation script on a system with fzf 0.44.1 (Debian/Ubuntu apt package)
- The installer creates
~/.fzf.zshwith the following content:
# Setup fzf
# ---------
if [[ ! "$PATH" == */home/user/.fzf/bin* ]]; then
PATH="${PATH:+${PATH}:}/home/user/.fzf/bin"
fi
source <(fzf --zsh)
- Source the file:
source ~/.zshrc - Error occurs:
unknown option: --zsh
Expected Behavior
The installation script should detect the fzf version and generate appropriate configuration:
- For fzf >= 0.48.0: Use
source <(fzf --zsh) - For fzf < 0.48.0: Use direct sourcing of shell integration files:
# Auto-completion
[[ $- == *i* ]] && source "$HOME/.fzf/shell/completion.zsh" 2> /dev/null
# Key bindings
source "$HOME/.fzf/shell/key-bindings.zsh"
Additional Issues with Older Versions
When manually fixing the source path, additional compatibility issues arise with the newer key-bindings.zsh file on fzf 0.44.1:
-
Error:
not a valid integer: 20+-
Location: Line 48 in
~/.fzf/shell/key-bindings.zsh -
Issue:
--min-height 20+syntax not supported -
Fix: Change to
--min-height 20
-
Location: Line 48 in
-
Error:
unknown action: toggle-raw-
Location: Lines 136 and 140 in
~/.fzf/shell/key-bindings.zsh -
Issue:
--bind=ctrl-r:toggle-sort,alt-r:toggle-rawuses unsupported action -
Fix: Remove
,alt-r:toggle-rawand--wrap-signoptions
-
Location: Lines 136 and 140 in
Proposed Solution
The installation script (install or install.sh) should:
- Check the installed fzf version
- Generate version-appropriate configuration in
.fzf.zsh - Either:
- Use
fzf --zshfor versions >= 0.48.0 - Fall back to direct file sourcing for older versions
- Or display a warning that shell integration requires fzf >= 0.48.0 and suggest upgrading
- Use
Impact
This affects users who:
- Install fzf from distribution package managers (apt, yum, etc.) which may have older versions
- Then run the official installation script expecting shell integration to work
- The
fzf --zshflag was added in a recent version, but many Linux distributions still ship 0.44.x or earlier
Workaround
Manually edit ~/.fzf.zsh to use direct file sourcing as shown in the "Expected Behavior" section above.
I removed from Linux package and installed from source code. It works for me.
I use Ubuntu 24.04. Shell: zsh
The reason you have this problem is that the install scripts appends the bin directory to your $PATH, instead of prepending to it.
It used to prepend, but we changed it to append at some point. See the commit message for the rationale:
- https://github.com/junegunn/fzf/commit/fdaa4e9b18a761dd0c60a1d4429c9f6c3eb58c96
I don't think there can be a solution that handles both cases well. (Unless we check and compare the versions by running fzf --version but that would increase the shell start-up time)
So for now, your options are to either:
- uninstall the outdated fzf from your package manager,
- or edit the generated file to prepend the directory to
$PATH.