In this blog, we’ll give you a brief introduction to Homebrew, a software package management tool. After reading this, you’ll learn a lot about Homebrew and be able to benefit from using it.
What is Homebrew?
Homebrew is a software package management tool that is free and open source. Using this software package, it is easy to install software on Apple OS, macOS, and Linux OS. It is called Homebrew because it is “home-made,” meaning it was developed by hobbyists and enthusiasts rather than large companies or official developers. Homebrew was developed by Max Howell, but over time, it became popular within the Ruby on Rails community.
The goal of Homebrew is to simplify the process of installing, updating and managing software. It allows users to install applications such as command-line tools, libraries and other software that may not be available in the macOS App Store or Linux repositories. The software installed via Homebrew is usually open source. Homebrew supports various types of development and productivity tools which relate to different programming languages, frameworks, database systems and utilities.
What are the key features and benefits of Homebrew?
You can easily install or manage software through Homebrew. You just need to use a simple command and through it, you can install, uninstall or upgrade software packages. For example, if you want to install Git, you can use the following command to install Git.
brew install git
When you install software, it often has multiple dependencies that also need to be installed. However, Homebrew automatically handles this task for you. It not only installs the software but also installs its dependencies, reducing the chance of errors and making the process much easier.
Homebrew is both customizable and extensible. When it comes to customization, Homebrew allows users to create custom “taps,” which are additional repositories providing access to more software packages. Additionally, users can create their own “formulas,” which are essentially installation scripts for software that isn’t available in the official Homebrew repository.
Homebrew’s installation packages are quickly available and it automatically installs the latest updates. If users want to ensure they have the latest version of Homebrew and its packages, they can use this specific command to update Homebrew with the latest changes.
brew update
Uninstalling software in Homebrew is just as easy as installing it. To uninstall a software package, you can use the following command:
brew uninstall package_name
And to clean up old or unused files, you can use this command:
brew cleanup
What are basic commands of Homebrew?
After discussing the key features and benefits of Homebrew, let’s list some basic commands that will make it easier for you to use Homebrew. These basic Homebrew commands are:
- Install a Package:
brew install package_name
- Uninstall a Package:
brew uninstall package_name
- Update Homebrew:
brew update
- Upgrade Installed Packages:
brew upgrade
- List Installed Packages:
brew list
- Search for a Package:
brew search package_name
How to install Homebrew?
To install Homebrew on macOS, run this command in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
On Linux, Homebrew requires some extra setup for Linux-specific dependencies. You can find complete instructions on the Homebrew website.
What are key components of Homebrew?
Homebrew has four key components, and we’ll briefly discuss each one:
- Formulae
Formulae are Ruby scripts designed to define how to install, upgrade, and configure software. Each formula contains information about the software, including its source, dependencies, and installation instructions. Homebrew’s core repository includes thousands of formulae that cover a wide range of software.
- Casks
A Homebrew “cask” is used for managing macOS applications that have a graphical interface. Casks enable you to install applications such as Google Chrome, VLC, or Visual Studio Code right from the command line. You can think of casks as Homebrew’s way of managing macOS apps, similar to how it handles command-line utilities.
brew install --cask google-chrome
- Taps
Taps are additional, user-created repositories. They extend Homebrew’s capabilities by allowing users to maintain their own collections of formulae and casks that aren’t part of Homebrew’s official core repository. For example, you can tap into other repositories by adding a GitHub URL.
brew tap user/repository
- Bottles
Bottles are precompiled binaries of software packages. When available, they save time by skipping the compilation process and allowing you to install software faster.
What are some advanced Homebrew commands?
- Pinning Packages
If you don’t want a specific package to be updated when you run brew upgrade
, you can pin it.
brew pin package_name
- Version Management
Homebrew allows you to install specific versions of software if multiple versions are available. Some packages also let you install alternative versions (e.g. Python 2 and Python 3).
brew install package_name@version
- Viewing Package Info
You can get detailed information about a package’s dependencies, installation path and more.
brew info package_name
- Running Services
Homebrew includes functionality for starting and stopping services which is helpful for applications like MySQL or PostgreSQL that need to run continuously.
brew services start package_name
brew services stop package_name
Conclusion
In this blog, we provided you with a basic introduction to Homebrew and shared some commonly used commands. We hope that after reading this article, you’re now quite familiar with Homebrew and ready to use it with ease. If you have any questions about Homebrew, feel free to ask them in our forum. Stay connected and stay happy!