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?
Apple's model of Git comes preinstalled on macOS. Open up your Terminal or shell script editor of choice and enter git --version to verify which version of Git is on your machine. If not already on your machine, running git --version will prompt you to install Git.
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.
Homebrew ships Git with a pre-built version (bottle) by default. You need to compile Git from source to enable PCRE support:
$ brew install pcre
$ export USE_LIBPCRE=yes
$ brew reinstall --build-from-source git
Now it should work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With