Getting Forem running on Apple Silicon

Intro

I recently bought an Apple Silicon based Mac Mini for my home office setup, and was excited to see if I could do development for with Forem on it. After a little bit of experimentation I have Forem running locally, and wanted to document the steps I took in case anybody else is curious or looking to make the switch.

The executive summary: it’s very possible to develop and run Forem on Apple Silicon without many changes, even at this early stage.

Some Background

First a bit of background: my day to day development environment is a 2019 15” MacBook Pro with a 2.3GHz 8-core i9 processor and 16 GB of memory. I develop Forem locally using the installation instructions for MacOS at https://docs.forem.com/installation/mac/

While my MacBook Pro (and all modern Macs before it) have Intel processors, the new Apple Silicon based Macs run on an ARM based M1 processor. Intel processors run executables compiled for x86 architecture, and the M1 runs code compiled for ARM64 architectures. These two processors basically speak difference languages.

It would be an huge problem if the Apple Silicon Macs couldn’t run x86 code as that would mean the last 20 some years of Mac software would be incompatible with them. As a stopgap measure Apple has a software translation layer called Rosetta 2 which can “translate” x86 executables on the fly to ARM64 code (important note: I am not a low level software engineer and this is a huge over simplification of Rosetta 2. Apple’s documentation about Rosetta 2 leaves a lot unexplained).

As an absolute low bar we could just run all of Forem (and associated development tools) under Rosetta 2 and call it a day. There’s a performance penalty, but the M1 chip is so fast that even under Rosetta 2 I’m finding most processes run just as fast as they did on my Intel based MacBook Pro.

The Simple Way

You can run any process in Terminal via Rosetta 2 by prepending the command arch -x86_64. So the easiest way to setup Forem on M1 is to just install the x86 version of everything.

Install Homebrew with Rosetta 2:

$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Then you can run Homebrew in in x86 mode by using:

$ arch -x86_64 brew

Typing that every times gets old really fast, so I created an alias in my ~/.zshrc file:

alias ibrew='arch -x86_64 /usr/local/bin/brew'

(the i is for Intel!)

Proceed with the rest of the installation instructions, and you’re done! Remember to use the ibrew alias so Homebrew installs the x86 version of packages.

The Complicated way

Sure, you can just run everything in x86 mode, but where is that fun in that: I bought an Apple Silicon Mac for it’s incredible performance, so let’s try to install as much as possible in the Arm64 architecture!

There’s early initial support for Apple Silicon in Homebrew, but they recommend installing both the x86 and Arm versions side by side as many Homebrew recipes haven’t been updated for Apple Silicon yet. I used Sam Soffe’s excellent write up to install both the x86 and Arm versions of Homebrew side by side.

After installing the x86 version of Homebrew, we’ll install Homebrew without the x86 prefix (which installs it as a native Arm64 executable), but we’ll do so in a different place than the default /usr/local/bin so we don’t overwrite our x64 Homebrew:

$ sudo mkdir -p /opt/homebrew
$ sudo chown -R $(whoami):staff /opt/homebrew
$ cd /opt
$ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

Finally, we’ll put this Arm64 Homebrew on our path before the x86 version. Back in our ~/.zshrc file:

export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"

Now if we want to install an x86 version of a package we’ll use ibrew, and if we want the Arm64 version of a package we’ll use brew.

Working through the Forem development environment setup instructions, as of January 5, 2021 I was able to use native Arm64 versions of everything except ElasticSearch and Ruby.

ElasticSearch is dependent on OpenJDK, which doesn’t have an Apple Silicon version ready yet.

Ruby works on Apple Silicon, as do most gems. The problem is any gem that has “native extensions” needs that extension to be built as an Arm64 version if you’re going to run it on Arm64 Ruby. Most do, but I ran into a few older gems that just wouldn’t build:

  • CLD is a very old gem used to language detection that just has no idea how to build on Apple Silicon. @fdoxyz played around with swapping it out for a new version in his great writeup on getting Forem to run on a Raspberry PI.
  • Several gems (notably the Twitter gem) use an older version of the http-parser gem that doesn’t build under Apple Silicon. Http-parser was just updated yesterday, so this might not be an issue any longer.
  • I was able to install the mini_racer gem successfully under Arm64, but ran into the error dyld: lazy symbol binding failed: Symbol not found when trying to actually run Rails.

Given these gem issues I’m using the x86 version of Ruby. While Ruby and friends do work just fine under Rosetta 2, there are a few idiosyncrasies because we have two versions of Homebrew install. First: I had both the Arm64 and x86 versions of the readline and openssl libraries installed. Since I’m building an x86 Ruby, I want it to use the x86 versions. To force ruby-build to use the proper libraries, I added the following to my ~/.zshrc:

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(ibrew --prefix openssl@1.1) --with-readline-dir=$(ibrew --prefix readline)"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

If you installed the Arm64 version PostgreSQL you’ll be missing the x86 version of libpq. I solved this by installing the x86 version of libpq, then adding it to the beginning of my PATH:

brew install libpq

Then in ~/.zshrc:

export PATH="/usr/local/opt/libpq/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"

Hopefully in the next few weeks these gems will be updated, or the Forem community will work on replacing/forking them.

And Docker fans…no, it’s not ready yet, but it’s in preview. Stay tuned.

Looking forward

Expect ** a lot** of changes in the coming weeks. I expect it won’t take too long for Arm versions of most Homebrew packages and native gems to be available. Two great sites for checking progress are Is Apple Silicon Ready? and Does It Arm?.

If you run into any problems developing or running Forem on Apple Silicon, please open an issue on our issue board.

Thoughts on announced 2020 iPad Pro and Magic Keyboard

An absolute deluge of iPad announcements were made today, including:

Not a ton seems to have changed on the iPad Pro: there are a bunch of new camera features (some to support enhanced augmented reality), but the processors only looks slightly improved. As someone who never uses his iPad for photography or AR, there’s not a lot here to tempt me to upgrade.

The bigger changes are around pointer support: iPadOS 13.4 will add native support for mice and trackpads as well as a lovely new Magic Keyboard cover with an integrated trackpad. It’s great to see iPadOS diverging in features from iOS as was promised back when it was split off last year. And yes: the Magic Keyboard will be backwards compatible with 3rd generation iPad Pro models https://www.macrumors.com/2020/03/18/new-magic-keyboard-supports-2018-ipad-pro/.

It’s a solid round of updates, and a testament to the initial design of the 2018 iPad Pro that there aren’t a ton of hardware changes to by made outside of small upgrades. I’m curious to see if the RAM situation has changed at all, but I’m not planning on upgrading this time. I’m absolutely going to grab that new Magic Keyboard cover, and I’m still hopeful WWDC 2020 will bring some way to develop apps on iPadOS.

I'm Joining the Team at DEV

This is my first week as a member of the team at DEV! I’m beyond excited to be joining this team of dedicated, passionate humans.

I’ve been a huge fan of the DEV community since way back when it started at @thepracticaldev on Twitter. As a longtime lurker (and very, very occasional contributor), I’ve learned so much from DEV community members sharing what they’ve learned. It’s time to give back, and I’m excited to get started!

A Little About Me

Hi there! 👋 I’m 42 years old, and live with my husband and daughter in Sturgeon Bay, Wisconsin: a tiny town on the shores of Lake Michigan. Our part of the state is in Door County, which is a popular tourist area: it’s a peninsula full of beaches, state parks, and cherry orchards. My family has been vacationing here since I was a baby, and a few years ago we were lucky enough to finally make this place our home. Expect the #DoorCounty hastag on DEV to blow up now that I’m here 😂

I’ve been a software engineer for two decades, working mostly in small startups. Most of my development work over the past few years has been with Ruby: I started using Rails with version 0.9. For the past decade I’ve worked remotely: remote work has allowed me to remain in this industry despite living far from a metro area.

When I’m not writing software, I’m an avid chef, photographer, and gamer. I’m also one of those crazy CrossFit people 🏋️‍♂️

Goals at DEV

The vast majority of my career has been spent in private, closed source software. I’m excited to be more involved with the open source community, and help DEV accomplish their longer term goals that Ben outlined in his recent post. I’m also going to be focused on helping the DEV team to be an even better remote team by lending my experiences working across multiple time zones.

Want to get in touch? My DM’s are open here, and I’m also available on twitter (@joshpuetz) or via email (josh@dev.to).

iPad Pro 12.9 (2018) impressions after three weeks

To say I’m a fan of the iPad would be an understatement. I’ve owned almost every iPad since the original model came out all the way back in 2010. The introduction of the iPad Pro in 2015 (along with the introduction of the Apple Pencil and Keyboard Cover) cemented the iPad as my primary non-work computer. Increasingly it’s becoming my work computer as well, something I’ll write about more in the future.

It should come as no surprise then that I pre-ordered the recently introduced third generated iPad Pro. I’ve been using a 12.9 iPad Pro with LTE for the last few weeks in a variety of environments (at home, on vacation, on a plane, and at a technical conference): here are my rough impressions of the hardware and software so far:

Hardware: iPad

  • The new design is gorgeous and feels great in the hand as well. I’d love to see this retro-future design move across the line to the iPhones next year.
  • It’s not really an edge-to-edge: there’s still a definite bezel (in which the Face ID sensors and front facing cameras are hidden).
  • Oleophobic coating hasn’t changed: the screen is still a terrible fingerprint magnet.
  • USB-C is a good change overall: the spec allows for faster charging times and re-use of dongles from my MacBook Pro. Of course if you don’t already own a raft of USB-C dongles you’ll have to build up a kit.
  • Camera bump is comically large due to the reduced thickness of the iPad. The Smart Keyboard Folio helps hide the bump, but if you use your iPad without a case it sits a bit unevenly on a flat surface.

Hardware: Smart Keyboard Folio

  • Feels much more stable in the lap due to single keyboard/cover piece that doesn’t have a seam like the previous model’s keyboard cover.
  • The downside of the single front cover piece is the loss of the “media configuration” of the old keyboard cover. The previous model could be folded around behind the iPad to enable it to be propped up at an almost vertical angle.
  • Having two keyboard angles is great: the more vertical setting is very close to the “media” configuration I mentioned, but the entire keyboard sticks out now in this viewing angle. Standing the iPad up on a shallow shelf isn’t possible anymore without the keyboard hanging over the shelf.
  • Feeling keys on the cover when it’s folded back feels like playing an accordion (or at least what I imagine it must feel like). It’s not a pleasant feeling, but suffices as the world’s most expensive fidget toy in a pinch.
  • Use of even more magnets in the folio means it’s still super-glued to metal cafe tables.
  • Magnets on viewing angle channels are just a bit too strong: folding up case takes some serious effort.

Hardware: Apple Pencil

  • It’s much easier to grip the new Pencil versus the old design due to flat edge and matte finish
  • Double tap action on the side of the Pencil is taking some getting used to. Due to the way I hold a pencil (pretty incorrectly) tapping the side of the Pencil while I’m holding it is a bit tricky. With practice I think it’ll still be faster than manually tapping an eraser icon in my note taking app (shout out to Notability)
  • Magnetic charging is awesome, but the Pencil doesn’t quite stay on when in a bag. I end up removing it before travel as a result.
  • Battery life seems reduced: I’ve definitely seen the battery dip down below 50% with extended usage. The ease of recharging the pencil by putting it into a storage position on the iPad reduces the real world impact of this however.

Software

  • Face ID feels more convenient than on an iPhone since I almost always have the iPad in front of me at a right angle.
  • Face ID feels faster overall, and the angle it detects my face is seems much wider and farther than Face ID on the iPhone X/Xs/Xr.
  • iOS 13 announcements at WWDC 2019 will really make or break the future of the iPad Pro: now that the hardware is set, the device feels like it needs software features to take advantage of it. Where are Apple’s pro level apps (like Logic and Final Cut Pro) for this device?