Search code examples
macosgithomebrewpcre

How to install Git with PCRE support on macOS with Homebrew?


When I run

$ git grep -P "<pattern>"

I get the following error:

fatal: cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE

How can I install Git with PCRE support for macOS properly?


Solution

  • With homebrew, just use

    brew reinstall --with-pcre2 git
    

    It forces to build git from source instead of downloading the bottle, but ensures that the updates will be done with the pcre support.