Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 471
ldiqual Avatar asked Feb 26 '14 23:02

ldiqual


People also ask

How do I download Git for Mac m1?

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.


2 Answers

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.

like image 64
Gaëtan Lehmann Avatar answered Sep 17 '22 12:09

Gaëtan Lehmann


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.

like image 42
ldiqual Avatar answered Sep 21 '22 12:09

ldiqual