Homebrew Big Sur



As you’ve already heard from everyone on the internet, including me, Apple’s new M1 computers are amazing. It’s freeing being able to unplug your computer in the morning, carry it around with you all day, and just not worry about about battery life, ever. And while the lower power usage is the best part, they’re also fast and quiet 1.

MacOS 11.0 (Big Sur) has been released to the public, and our goal is for Homebrew to support it. How the feature would be relevant to at least 90% of Homebrew users In the long run, more than 90% of Homebrew (macOS) users are going to run Apple Silicon hardware. The location where brew gets installed in macOS Big Sur is /opt/homebrew/bin/ code2care@mac bin% pwd /opt/homebrew/bin code2care@mac bin% ls brew code2care@mac bin% Brew installation location.

If you are on macOS Catalina or Big Sur (or any future release), you can not use the root folder for this purpose. MacOS Catalina runs in a read-only system volume, separate from other files on the system. Apple created a secondary volume on Catalina that you need to use for storing MongoDB data folder. Homebrew and Apple Silicon If you’re experiencing any other issues with Homebrew, check their Github account before freaking out. Not everything is currently supported on Big Sur, but they’re working on it. The other massive project in progress is supporting Apple Silicon.

Despite all the gains, I was reluctant to recommend them because of the Intel to Apple Silicon switching pains. As with PowerPC to Intel a decade ago, Rosetta works practically flawlessly, but there was still one major catastrophe in progress: Homebrew.

Mac big sur homebrew

Some programs worked, but many didn’t, and the team’s recommendation was to keep two versions of Homebrew installed simultaneously, one for ARM, and the other for x86 to be run under Rosetta. It wasn’t that bad, but computers waste so much of your time already that why eat the pain when you can just wait another few months and have the problem disappear.

After running into Homebrew-related trouble installing Ruby 3 yesterday, I checked in on Homebrew’s M1 transition, and was very pleased to see that it’s much further along even compared to a few weeks ago. Almost everything works, and many formulae are now shipping with bottles for arm64_big_sur (“bottle” is Homebrew’s term for a pre-built binary), reducing trouble and saving installation time. They’ve integrated Go’s 1.16 beta, which adds ARM support, which unblocks many other programs that depended on it.

Today, I removed my Intel installation completely, successfully reinstalling everything that’d been in it to the ARM instead. What remains are fast ARM binaries, and a much less confusing setup.

So I’m pulling out the stopper on M1 Macs, and recommending them unconditionally. They’re new enough that I’d expect more problems to still exist, but with Homebrew in a good place, there’s none even worth mentioning anymore. Go get one.

Homebrew Big Sur

1 Also: if you’re upgrading from the last few years of MacBook Pro, butterfly keys are gone, and so is the Touch Bar if you go with the Air.

Fragment
Homebrew on M1 is a go

Published
January 9, 2021

Find me on Twitter at @brandur.

Did I make a mistake? Please consider sending a pull request.

Homebrew Postgres on Big Sur

I recently ran into an issue with Postgres after upgrading to Big Sur. This is pretty typical for me after OS updates; the feedback loop between updates is too long for my memory. After flailing and staring at countlessStackOverflowthreads, I found my way out of the woods. Here’s my particular breadcrumb trail.

After starting my local Rails server after the OSX upgrade, I was greeted with the dreaded error “connection to database failed: could not connect to server: No such file or directory”. I rushed through my typical fix of deleting the postmaster.pid which usually gets left behind when my machine restarts only to find that this can cause worse problems when done incorrectly. I then when through my typical debugging questions:

  1. Which install of Postgres am I running?
  2. And which version of Postgres am I running?

Homebrew Big Sur California

Debugging

When I get stuck, I take a deep breath and gather up my assumptions. In this case, I know that Postgres can be installed a number of different ways, and I want to verify how the software is installed. I like installing Postgres via homebrew. With a quick command in the terminal, which postgres, I see that it’s installed in /usr/local/bin which I know is where homebrew installs. Next, I check the version with postgres --version and I get back 13.x which is not the 12.x I expected.

Now I had two options:

  1. Bring my install up to the latest, 13.x or
  2. Revert my install to 12.x.

I’m a believer in intentional upgrades and intentional changes. I want to minimize the surface area and variables between known working versions of my software. The best way to do that would be to walk my local copy back to 12.x.

Downgrading Postgres

This was the trickiest part. I needed to install 12.x and then point homebrew at the install.

Installing the older version of Postgres wasn’t too bad. brew install postgres@12.5got the old version my app was expecting onto my machine. But checking the postgres version still returned the new Postgres install. That makes some sense. Homebrew wasn’t installing the old version of Postgres over the existing 13.x. It was allowing both to be installed on my machine. After fumbling with a few commands and various Stack Overflow posts, I discovered brew link --overwrite postgresql@12. This pointed the postgres command at the latest version. Checking the version through the terminal confirmed this. But we’re not quite there yet.

Running Postgres

Finally, I had to restart Postgres. I began by checking which brew services were running with brew services list. From here, I could see that postgres@12 was stopped. A quick start kicked the service off brew services start postgresql@12. It’s important to note that even though I had linked brew to the old postgres version, when I was running brew commands, I still needed to reference the appropriate brew Postgres install, hence the @12.

Homebrew Big Sur Intel

Next Steps

With this, I could restart Rails and get my app up and running again. A few notes:

  • Postgres 13 is still installed on my machine. I should remove it or otherwise plan on upgrading my app to it. I’m really unsure of what state the install is in, and it’s likely to trip me up in the future if I don’t handle it here while I have this context in my hed.
  • I went this route as I really wanted to hold on to the data I had in my local DBs. If I was just getting started or I didn’t care about losing that data, I likely would have blown everything away and run rails db:prepare and been up and running with Postgres 13.

Hopefully, you see some of your own Postgres situation in my particular path, and you can hop on somewhere and get to your own solution. If not, reach out. I’d love to learn more about how to debug Postgres installs.

Sur

Big Sur Install Homebrew

References

Homebrew Big Sur Path