The Homebrew venture started its life as an unofficial Linux-style package deal supervisor for the Mac. Its customers shortly fell in love with its pleasant interface and useful prompts, and—in what could appear to be a unusual coincidence—it bought ported to Linux.
At first, there have been two separate tasks for macOS and Linux (Homebrew and Linuxbrew), however now Homebrew’s core manages each working techniques. Because I have been on a journey to migrate from Mac to Linux, I’ve been taking a look at how my favourite open supply functions for macOS carry out on Linux, and I have been glad to seek out that Homebrew’s help for Linux really shines.
Why Homebrew on Linux?
An inexpensive first response to Homebrew from long-time Linux customers is: “Why not just use…” the place the subsequent phrase is a package deal supervisor for his or her most popular model of Linux. Debian-based techniques have already got
apt, Fedora-systems have
yum, and tasks like Flatpak and AppImage work to span the hole by working easily on each. I’ve spent an honest period of time utilizing all these applied sciences, and I’ve to say every one is highly effective in its personal proper.
So why do I stick with Homebrew? First off, it is extremely acquainted to me. I am already studying loads as I transition to extra open supply alternate options for my previous proprietary instruments, and retaining one thing acquainted—like Homebrew—helps me give attention to studying one factor at a time as an alternative of being overwhelmed by all of the variations between working techniques.
Also, I’ve but to see a package deal supervisor that’s as variety to the person as Homebrew. Commands are nicely organized, because the default Help output reveals:
$ brew -h
brew search [TEXT|/REGEX/]
brew information [FORMULA...]
brew set up FORMULA...
brew improve [FORMULA...]
brew uninstall FORMULA...
brew record [FORMULA...]
brew set up --verbose --debug FORMULA
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
brew assist [COMMAND]
This brief output may be mistaken as a limitation, however a fast look inside any of the subcommands reveals a wealth of performance. The record above is simply 23 strains lengthy, however the
set up subcommand has a whopping 79 strains of knowledge accessible for the superior person:
$ brew --help | wc -l
$ brew set up --help | wc -l
It has choices for ignoring or putting in dependencies, selecting to construct from supply and with what compiler, and utilizing precise upstream Git commits versus the official “bottled” model of the appliance. Suffice it to say, Homebrew is for consultants and novices alike.
Get began with Homebrew on Linux
If you wish to give Homebrew a strive, there’s a nice one-liner script to put in it on Mac or Linux:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
This command executes the Homebrew installer script instantly. If you’re extra cautious, you’ll be able to
curl the file, then run it manually after a assessment:
$ curl -fsSL https://uncooked.githubusercontent.com/Homebrew/set up/grasp/set up.sh --output homebrew_installer.sh
$ extra homebrew_installer.sh # assessment the script till you are feeling comfy
$ bash homebrew_installer.sh
The Linux directions embrace configurations for dotfiles, significantly
~/.profile on Debian techniques and
~/.bash_profile on Fedora:
$ check -d /house/linuxbrew/.linuxbrew && eval $(/house/linuxbrew/.linuxbrew/bin/brew shellenv)
$ check -r ~/.bash_profile && echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
$ echo "eval $($(brew --prefix)/bin/brew shellenv)" >>~/.profile
To affirm the set up, the Homebrew crew supplies an empty
hiya method for testing:
$ brew set up hiya
==> Downloading https://linuxbrew.bintray.com/bottles/hello-2.10.x86_64_linux.bottle.tar.gz
==> Pouring hello-2.10.x86_64_linux.bottle.tar.gz
🍺 /house/linuxbrew/.linuxbrew/Cellar/hiya/2.10: 52 information, 595.6KB
It seems to be like my set up is working with none points, so I am going to discover somewhat extra.
Brew for command-line utilities
Homebrew boasts of being an utility that “installs the stuff you need that [Linux] didn’t” by default.
You use the
brew command to put in any of the command-line utilities packaged up in Homebrew. These package deal definitions are referred to as “formulae,” and they’re compiled and shared via “bottles.” There is a bunch of different beer-oriented terminology within the Homebrew universe, however the package deal supervisor’s important takeaway is to make software program simply accessible.
What form of software program? Think in regards to the issues that come in useful for nerds like me (and, because you’re studying this, most likely you, too). For instance, the useful
tree command that reveals listing buildings or
pyenv, which I take advantage of to manage multiple versions of Python on a Mac.
You can see all formulae accessible utilizing the
search command, and including the
wc command reveals what number of can be found:
# -l counts the variety of strains
$ brew search | wc -l
There are over 5,000 formulae so far, which is an unbelievable quantity of software program. The caveat is that not each method will run on Linux. There is a piece within the output of
brew search --help that reveals flags to filter software program by the working system it runs on. It launches every working system’s repository record to a browser. I am working Fedora, so I am going to give it a strive with:
$ brew search --fedora tree
The browser hundreds
https://apps.fedoraproject.org/packages/s/tree, which reveals the choices accessible for Fedora. There are different methods to browse, as nicely. Formulae are codified and centralized into the core repositories which might be break up out by working system (Mac in Homebrew Core and Linux Core for Linux bits). They are additionally accessible via the Homebrew API and listed on the website.
Even with all these choices, I nonetheless discover most of my new instruments via suggestions from different customers. Here are a few of my favorites, if you happen to’re in search of inspiration:
nodenvto handle Python, Ruby, and Node.js variations (respectively)
imagemagickfor scriptable picture edits
pandocfor scriptable doc conversions (I usually change from .docx to .md or .html)
hubfor a better Git experience for GitHub customers
tldrfor examples of tips on how to use a command-line utility
To discover Homebrew, check out tldr pages, which is a user-friendly different to scrolling via an utility’s man pages. Confirm it is accessible by working
$ brew search tldr
Success! The checkmark lets it’s accessible. Now you’ll be able to set up it:
$ brew set up tldr
==> Downloading https://linuxbrew.bintray.com/bottles/tldr-1.three.0_2.x86_64_linux.bottle.1.tar.gz
==> Pouring tldr-1.three.0_2.x86_64_linux.bottle.1.tar.gz
🍺 /house/linuxbrew/.linuxbrew/Cellar/tldr/1.three.0_2: 6 information, 63.2KB
Homebrew serves up prebuilt binaries, so you do not have to construct from supply code in your native machine. That saves quite a lot of time and CPU fan noise. Another factor I recognize about Homebrew is which you could recognize this characteristic with out understanding precisely what it means. If you like to construct it your self, use the
--build-from-source flag with
brew set up to compile the method from supply (even when a bottle exists).
Similarly, the complexity below the hood might be fascinating. Running
tldr reveals how dependency administration occurs, the place the supply code of the method sits on disk, and even the general public analytics can be found:
$ brew information tldr
tldr: steady 1.three.zero (bottled), HEAD
Simplified and community-driven man pages
tealdeer (as a result of each set up `tldr` binaries)
/house/linuxbrew/.linuxbrew/Cellar/tldr/1.three.0_2 (6 information, 63.2KB) *
Poured from bottle on 2020-06-08 at 15:56:15
Build: pkg-config ✔
Required: libzip ✔, curl ✔
Install HEAD model
set up: 197 (30 days), 647 (90 days), 1,546 (365 days)
install-on-request: 197 (30 days), 646 (90 days), 1,546 (365 days)
build-error: zero (30 days)
One limitation from Mac to Linux
On macOS, the Homebrew
cask subcommand affords customers a approach to set up and handle whole functions utilizing the identical nice command-line utility. Unfortunately,
cask doesn’t but work on any Linux distributions. I discovered this out whereas attempting to put in an open supply instrument:
$ brew cask set up tusk
Error: Installing casks is supported solely on macOS
I requested about it on the forum and bought some fast suggestions from different customers. In brief, the choices are to:
- Fork the venture, construct the characteristic, and present others that it is worthwhile
- Write a method for the appliance and construct from supply
- Create a third-party repository for the appliance
The final one is probably the most fascinating to me. Homebrew manages third-party repositories by creating and maintaining “taps” (one other beer-influenced time period). Taps are price exploring as you get extra accustomed to the system and wish to add to the ecosystem.
Backing up Homebrew installs
One of my favourite Homebrew options is how one can again up your set up similar to some other dotfile in version control. For this course of, Homebrew affords a
bundle subcommand that holds a
dump subcommand that generates a Brewfile. This file is a reusable record of all of your at present put in instruments. To generate a Brewfile out of your set up, go into whichever folder you wish to use and run:
$ cd ~/Development/dotfiles # This is my dotfile folder
$ brew bundle dump
$ ls Brewfile
When I alter machines and wish to arrange the identical functions on it, I’m going to the folder with the Brewfile and reinstall them with:
$ ls Brewfile
$ brew bundle
It will set up all of the listed formulae on my new machine.
Brewfile administration throughout Mac and Linux
The Brewfile is a good way to backup your current set up, however what if one thing on Mac would not run on Linux or vice versa? What I’ve discovered is that Homebrew will gracefully ignore the strains that do not work on a given working system, whether or not Mac or Linux. As it comes throughout incompatible requests (like asking brew to put in casks on Linux), it skips them and continues on its means:
$ brew bundle --file=Brewfile.instance
Skipping cask licecap (on Linux)
Skipping cask macdown (on Linux)
Homebrew Bundle full! 1 Brewfile dependency now put in.
To hold my configuration so simple as doable, I take advantage of the identical Brewfile throughout each working techniques and have not run into a problem because it installs the OS-specific model every time I run it.
Homebrew for package deal administration
Homebrew has been my go-to supervisor for command-line utilities, and its familiarity makes my Linux expertise that rather more fulfilling. Homebrew retains me organized and updated, and I proceed to understand its steadiness between ease of use and depth of performance. I choose to maintain package deal administration particulars to the minimal quantity of knowledge a person must know, and most of the people will profit from that. If you are already comfy with Linux package deal managers, Homebrew could come off as easy, however trying somewhat deeper reveals its superior choices that go far past what’s on this article.
There are quite a lot of package deal administration choices for Linux customers. If you’re coming from the world of macOS, Homebrew will really feel like house.