Is there a brew --with-debug-flag-set package style command available to get brew to build a package that includes debug information.

Specifically, I would like clisp to be built this way so that disassemble works in the repl.

I imagine something along the lines of:

brew install clisp --with-debug

or somesuch.

3 Answers 3


According to Mike McQuaid (Lead maintainer of Homebrew) this is not possible.

  • Not directly, but the compile flags should allow it. I've added a basic example in a separate reply. :)
    – tresf
    Jun 20, 2018 at 15:07
  • This is no longer true. See my answer. Oct 4, 2022 at 18:27

A brew formula is a Ruby (.rb) file that contains the compile options inside. Homebrew's brew install|reinstall allows specifying a URL instead of a formula name, so compile flags can be added to an online copy of the formula and hosted on a service like gist.github.com.

Here's an example ruby file that has an overridden compile option.

def install
   args = std_cmake_args

   # OVERRIDE: Force cmake to use debug flags
   args << "-DCMAKE_BUILD_TYPE=Debug"

   system "cmake", ".", *args

std_cmake_args, defined in Homebrew's interneal formula.rb is a variable internal to all Homebrew cmake formula and provides sane defaults to each cmake build prior to adding additional arguments.

This example uses cmake, each project will have its own compiler tools and thus potentially different technique(s) for adding compile flags. For example, to tell cmake to use Debug flags, it's args << "-DCMAKE_BUILD_TYPE=Debug"

Once these changes have been made to the .rb file and hosted online, you can reinstall the package with the new options using the --build-from-source command line option.

brew reinstall --build-from-source https://<path to formula>.rb
  1. WARNING: If using gist.github.com, note that the "Raw" version is the URL that you want. If not, it'll try to install the HTML (e.g. code preview) of the page, which won't work. :)

  2. WARNING: Remember, this will reinstall the specified package in the Homebrew directory with debug flags, so the old "release" or "optimized" build will not longer be available. So please remember to reinstall the non-debug version using the standard brew install technique once troubleshooting has been completed or else you'll have a debug version of a library on your computer until it's manually updated. :)

  • I get an error when trying this: "Error: Non-checksummed download of sdl2 formula file from an arbitrary URL is unsupported! brew extract or brew create and brew tap-new to create a formula file in a tap on GitHub instead." May 16, 2022 at 0:19
  • Yeah, unfortunately Homebrew killed this technique, so the answer is outdated. They want contributors to fork/tap the repository instead now, which is a few more steps.
    – tresf
    May 17, 2022 at 1:24

As of the most recent update, you can now do this by adding the --debug-symbols option to brew install.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .