'Unable to uninstall brew php from homebrew

I am trying to uninstall [email protected] using homebrew but it keeps on saying Error: No such keg: /usr/local/Cellar/[email protected] how to uninstall it and what is keg?



Solution 1:[1]

Had the same error (OS Mojave 10.14) with local php 7.1 needing for update. Issue was when trying to install PHP version with homebrew the installation didn't work because of a curl error - solution was to use brewed curl instead of system curl

Initially tried:

brew install shivammathur/php/[email protected]  

Reponse was:

Error: Failed to download resource "freetds"

used the following command to update the errored package freetds myself:

HOMEBREW_FORCE_BREWED_CURL=1 brew install freetds

After this ran the homebrew php command again (update took very long):

brew install shivammathur/php/[email protected] 

Then forced the php7.4 version

 brew link --overwrite --force shivammathur/php/[email protected]

And then

php -v

And succcess:

PHP 7.4.28 (cli) (built: Apr  3 2022 20:51:36) ( NTS )

Hope this saves someone a day!

Answer found here: reference

Solution 2:[2]

Keg is the term homebrew uses for a package (AFAIK, the terms confuse me a lot still).

So it means there is no package found called [email protected]. Are you sure that is the version you have installed. It might just be called php.

You can run brew list to find all installed packages and look for one the looks like it could be the php package you are trying to uninstall.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3615851
Solution 2 Alex Bouma