How do I modify a Homebrew formula?

I installed ImageMagick via Homebrew.

However, due to a bug I have with my current configuration, I need to adjust the compile flags for the formula and reinstall it.

How can I accomplish this?


Remove the existing version.

$ brew rm imagemagick

Edit the formula.

$ brew edit imagemagick

This will bring it up in an editor; make sure your $EDITOR variable is set to your preference (for me: TextMate)

Change it, save it, try re-installing it.

Because most installs use pouring/bottles to install a precompiled binary, you will likely see no change unless you "build from source":

$ brew reinstall --build-from-source [...]

You can use --formula /path/to/imagemagick.rb as an additional argument to the above command to ensure brew is installing the formula that was edited.

If you're comfortable with git, you may also want to make a branch first, and do your edits in a branch to guard against data loss.