Site icon ashishb.net

How to add a new formula to homebrew package manager

I recently added adb-enhanced to the Homebrew package manager. Here are some of my learnings and future tips to smoothen up the process.

The best way to create and test Formula is to first install Homebrew and then follow the following steps for faster merge

# Change "adb-enhanced" with your preferred formula name everywhere
# Create a new formula via
$ brew create --set-name adb-enhanced
# In the editor, fill in the details, regarding the formula
# You can see mine as a reference at https://github.com/Homebrew/homebrew-core/blob/e8e49e89e84a6412ffadce73b24579af986b2e10/Formula/adb-enhanced.rb
# Depending on whether your formula is based on Go, Python, Rust, Java, there are different ways to build the code
# homebrew won't accept a formula being distributed as a binary

# Verify that formula can be installed
$ brew install --build-from-source adb-enhanced
# Some bare minimal tests are also required
$ brew test adb-enhanced
# This auditing ensures that the formula is acceptable to homebrew
$ brew audit --new adb-enhanced && brew audit --strict adb-enhanced 
# These reflects another set of slightly different test that homebrew CI would run
$ brew install --verbose --build-bottle adb-enhanced
$ brew install --include-test adb-enhanced
$ brew link adb-enhanced
$ brew test --verbose adb-enhanced

Once you are done, clone the homebrew repo and add your formula to it. Now, send a pull request to merge it.

Exit mobile version