Creating Your Own Homebrew Tap

Mon Jan 4, 2021

Creating my own homebrew tap

I spend most of my day in linux, and the rest of the time in osx. I’ve been writing a bunch of command line tools here and there. The easiest way to share them with others is to create homebrew formulae or casks. However, if your project isn’t popular enough, you won’t be added to homebrew-core. Thus you can create your own homebrew tap where you can share your formulae and casks with the world, and other people can install your software by typing homebrew install <username>/tapname/whatever.

cannot run gpg when brew tap-new

First thing you do when creating your own tap is brew tap-new. I immediately encountered the error “cannot run gpg” because I have my commits signed with a git post-hook. It turns out that homebrew excludes some environment variables by default, and GPG_TTY is one of them.

brew tap-new -v dherbst/homebrew-tap
git init
Initialized empty Git repository in /usr/local/Homebrew/Library/Taps/dherbst/homebrew-tap/.git/
git add --all
git commit -m Create dherbst/tap tap
error: cannot run gpg: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
Error: Failure while executing; `git commit -m Create\ dherbst/tap\ tap` exited with 128.

The solution was to include the variable HOMEBREW_NO_ENV_FILTERING="1" when creating the tap. This preserves the GPG_TTY variable and gpg runs as it normally does.