fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Installation script incompatible with fzf < 0.48.0 (--zsh flag)

Open mehtachandrashekhar opened this issue 2 months ago • 2 comments

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

  1. Install fzf using the official installation script on a system with fzf 0.44.1 (Debian/Ubuntu apt package)
  2. The installer creates ~/.fzf.zsh with the following content:
# Setup fzf
# ---------
if [[ ! "$PATH" == */home/user/.fzf/bin* ]]; then
  PATH="${PATH:+${PATH}:}/home/user/.fzf/bin"
fi

source <(fzf --zsh)
  1. Source the file: source ~/.zshrc
  2. 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:

  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
  2. 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-raw uses unsupported action
    • Fix: Remove ,alt-r:toggle-raw and --wrap-sign options

Proposed Solution

The installation script (install or install.sh) should:

  1. Check the installed fzf version
  2. Generate version-appropriate configuration in .fzf.zsh
  3. Either:
    • Use fzf --zsh for 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

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 --zsh flag 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.

mehtachandrashekhar avatar Oct 25 '25 18:10 mehtachandrashekhar

I removed from Linux package and installed from source code. It works for me.

I use Ubuntu 24.04. Shell: zsh

juliosouzam avatar Nov 07 '25 02:11 juliosouzam

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.

junegunn avatar Nov 09 '25 01:11 junegunn