MacOS – Brew cask: I would like to check if the package/formula is already installed through brew or other means

homebrewinstallmacos

I am trying to install some softwares using brew cask and I would like to check if the package/formula is already installed through brew or other means

I have a script that installs a list of softwares using brew cask and I dont want it to install a software that is already present on the machine

To achive this I referred to this question: With Homebrew, how to check if a software/package is installed?

This is pointed me in the right direction but I can only avoid installing software that is installed via brew cask.

If the software is installed by downloading the dmg and is already present in the /Applications/ folder then it does not recognize that and it continues to install the software.

Is there a way to figure out if the application is installed via brew or any other means before my script starts installing it

Best Answer

I assume you know the name of the application. Then just test for existence of the application

if [[ ! -d "/Applications/APP-TO-CHECK.app" ]]; then
    # install APP-TO-CHECK
fi