DEV Community

Cover image for pcre2.h - file not found. How to fix that when installing PCOV on macOS?
Matheus Lopes Santos
Matheus Lopes Santos

Posted on

pcre2.h - file not found. How to fix that when installing PCOV on macOS?

For some reason, I managed to mess up the PHP installation on my operating system. Well, no biggie, let's uninstall and reinstall it, no problem.

I installed the main extensions I use, and when I tried to install pcov - boom, a fatal installation error occurred:

homebrew error

Cool, all I need to do is install pcre2, right? 🙂

But it wasn't that simple. When I ran brew install pcre2, I was informed that it was already installed.

pcre2

Fixing the Issue

I checked some tutorials but couldn't find anything. I even tried creating a symbolic link for the "missing" file, but without success:

ln -s /opt/homebrew/Cellar/pcre2/10.42/include/pcre2.h /opt/homebrew/Cellar/php/8.2.10/include/php/ext/pcre/php_pcre.h
Enter fullscreen mode Exit fullscreen mode

So, it was time for the brute force approach. Searching by myself, I found out how to solve that problem:

ln -s /opt/homebrew/opt/pcre2/include/pcre2.h /opt/homebrew/opt/php@8.2/include/php/ext/pcre/
Enter fullscreen mode Exit fullscreen mode

After that, just run pecl install pcov, and you're good to go!

pcov-instalado

Now I'm able to calculate the code coverage of my applications again.

That's all, folks! 😗 🧀

Top comments (3)

Collapse
 
leslieeeee profile image
Leslie

Have you tried ServBay.dev?
It's a much easier tool for PHP developers, providing a user-friendly experience, especially for beginners. It supports all versions of PHP, MariaDB, PostgreSQL, as well as Redis and Memcached. You can run multiple PHP instances simultaneously and switch between them effortlessly. It also offers easy updates without the need to configure environment variables. This tool has greatly simplified my PHP development and is definitely worth trying!

Collapse
 
devlopez profile image
Matheus Lopes Santos

Hello my friend, how are you doing today? I've never heard about this tool. I'll take a look. Thank you for sharing ❤️

Collapse
 
leslieeeee profile image
Leslie

It's a new product, but very useful!