What directory does homebrew use to build programs?

I would like to change the directory that homebrew uses when it builds programs

Is that possible? I didn't find such option in brew command


When you install a Homebrew package, if it needs to compile it from source, it will extract the files to /tmp/package-XXXXXX and compile them there before installing to /usr/local/Cellar/package.

You can specify a different temp folder by setting an environment variable...

export HOMEBREW_TEMP=/Users/USERNAME/Desktop/temp

The manpage of Homebrew version 0.9.9 suggest something different:

the default folder Hombrew uses to do his things (including compiling) is ~/Library/Caches/Homebrew, and you can change it by setting HOMEBREW_CACHE environmental variable. The environmental variable can be set by editing the hidden file .bash_profile in the user folder, e.g.:

nano ~/.bash_profile

then add

export HOMEBREW_CACHE=/path/to/folder

Remember to do a source ~/.bash_profile to load the new environmental variable in already opened terminal sessions.

Brew manpage about HOMEBREW_TEMP:

HOMEBREW_TEMP

    If set, instructs Homebrew to use HOMEBREW_TEMP as the temporary directory
    for building  packages.
    This  may be needed if your system temp directory and Homebrew Prefix are
    on different volumes, as OS X has trouble moving symlinks across volumes
    when the target does not yet exist.

    This issue typically occurs when using FileVault or custom SSD configurations.

Unless this fits your settings, you should avoid setting HOMEBREW_TEMP.