How do I "replay" the "Caveats" section from a homebrew recipe

MacosHomebrew

Macos Problem Overview


When installing a homebrew recipe, you occasionally will get some useful information in the "Caveats" section that you may want to tuck under your hat. Is there any way to replay or access this information once it has been displayed at install or is it lost forever unless you copy paste somewhere?

e.g.

==> Caveats
To have launchd start mongodb at login:
    ln -s /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/
Then to load mongodb now:
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
    mongod

I might want to be able to see this again and/or know where that plist is if I want it later.

tl;dr How do I see the above snippet again after I've installed something from homebrew?

Macos Solutions


Solution 1 - Macos

brew info mongodb will display it. If you make the changes suggested by the Caveats however, there may be other Caveats presented which will be more applicable to your actual situation.

Solution 2 - Macos

I created a brew external command for that: https://github.com/rafaelgarrido/homebrew-caveats

$ brew caveats zsh
==> zsh: Caveats
Add the following to your zshrc to access the online help:
    unalias run-help
    autoload run-help
    HELPDIR=/usr/local/share/zsh/helpfiles

You can also pass multiple formulas:

$ brew caveats rabbitmq mongodb
==> rabbitmq: Caveats
Management Plugin enabled by default at http://localhost:15672

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

To have launchd start rabbitmq at login:
  ln -sfv /usr/local/opt/rabbitmq/*.plist ~/Library/LaunchAgents
Then to load rabbitmq now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
Or, if you don't want/need launchctl, you can just run:
  rabbitmq-server

==> mongodb: Caveats
To have launchd start mongodb at login:
  ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
  mongod --config /usr/local/etc/mongod.conf

Pretty handy when you need to check some configs!

Solution 3 - Macos

To see all caveats of the currently installed formulas you can use the following command

brew info $(brew list)

You can also filter the output with awk to only get the caveats sections. (I am an awk newbie suggestions or edits are welcome)

brew info $(brew list) | awk '/^==> Caveats$/,/^[a-z][a-zA-Z0-9_+-]+: stable |^==> (Dependencies|Options)$/'

Solution 4 - Macos

Another possibility is to use sed

brew info $(brew list) | sed '/==> Caveats/,/==>/!d;//d'

And to have a formatted output (bash)

for cmd in $(brew list); do 
  if brew info $cmd | grep -q Caveats; then
    echo "$cmd\n"; 
    brew info $cmd | sed '/==> Caveats/,/==>/!d;//d'; 
    printf '%40s\n' | tr ' ' -; 
  fi; 
done;

Solution 5 - Macos

For those of you who have the awesome jq tool:

# For brews
$ brew info --json $(brew list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'

# For casks
$ brew cask --json=v1 info $(brew cask list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'

jq is a command-line JSON processor.

Solution 6 - Macos

Updating and combining a few above anwers, here's a bash/zsh loop that can be pasted into the terminal to get all caveats for all installed brew formulae.

for x in $(brew list --formula); do 
	cavs=$(brew info "$x" | sed '/==> Caveats/,/==>/!d;//d')
	if [ ! -z "$cavs" ]; then
		echo "$x"
		echo "---"
		echo "$cavs"
		echo ""
	fi
done

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwmarbutView Question on Stackoverflow
Solution 1 - Macosuser149341View Answer on Stackoverflow
Solution 2 - MacosRafa GarridoView Answer on Stackoverflow
Solution 3 - Macos166_MMXView Answer on Stackoverflow
Solution 4 - Macosd4krView Answer on Stackoverflow
Solution 5 - MacosRichardView Answer on Stackoverflow
Solution 6 - MacosmathandyView Answer on Stackoverflow