My New Hugo Site

Syncthing on Dinosaur MacBookPro

Some background story. I have a MacBookPro 2015 refuses to die. Instead of turning it to electronic waste, I turned it into a home server serving photos with Immich. Let’s called this MacBook alanine.

I have another MacMini as daily use desktop, named glutamine. Photos directory is synced between these two Macs using Syncthing. Because of alanine’s age, brew install syncthing wouldn’t work straight away because it’s complaining it cannot install go.

After some digging around the homebrew-core formulas, it is because the latest stable version go@1.25 ditched supporting macOS 11 Big Sur. To git a copy of these formulas, the proper way is brew tap homebrew/homebrew-core. This command will git clone the mentioned repository to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/. Some sources tell me this clone is not necessary to make my changes of formulas anymore, but I’ll just leave it there without more side quests. At the time of this writing, HEAD is pointing to commit e6c69403.

go@1.24

go@1.24 supports macOS Big Sur. However brew install go@1.24 still doesn’t work. After more digging, this is because of this line in go@1.24.rb:

depends_on "go" => :build

This tells homebrew that it needs the go formula, which is pointing to version 1.25, if I want to build go@1.24 from source. Three things are happening here:

  1. Because the macOS is too old, it refuses to brew install go@1.24 --force-bottle. If installing from bottle work, we can avoid building from source, in turn avoiding install go@1.25.
  2. Building go@1.24 from source requires go.rb because other versions of go is using go to compile.
  3. I cannot change go.rb to compile go@1.24 from source using gcc.

After these pain, I ditch installing go from homebrew. Using the official macOS installer is much much more straightforward and pain-free.

syncthing

Changing the formula for syncthing.rb is much less pain.

diff --git a/Formula/s/syncthing.rb b/Formula/s/syncthing.rb
index e34c166a893..7dcd3709580 100644
--- a/Formula/s/syncthing.rb
+++ b/Formula/s/syncthing.rb
@@ -20,11 +20,11 @@ class Syncthing < Formula
     sha256 cellar: :any_skip_relocation, x86_64_linux:  "f3d722618ab290f1a1cd88309939582c1750a08cf697aff955098103539d3087"
   end

-  depends_on "go" => :build
+  # depends_on "go" => :build

   def install
     build_version = build.head? ? "v0.0.0-#{version}" : "v#{version}"
-    system "go", "run", "build.go", "--version", build_version, "--no-upgrade", "tar"
+    system "/usr/local/go/bin/go", "run", "build.go", "--version", build_version, "--no-upgrade", "tar"
     bin.install "syncthing"

     man1.install Dir["man/*.1"]
  1. Commenting out the go dependency managed using homebrew, because we now have go installed from official installer.
  2. Absolute path for go is used because the homebrew shell doesn’t have go in its $PATH variable. I think this is because the /etc/paths.d/go file only applies to interactive shell.

Finally, brew install syncthing.rb. :)


update

When I was trying to install and older version of CMake, I bumped into this tutorial on how to properly install an old formula in homebrew. Having done this successfully on CMake, I turned my eyes to fixing go. Following the steps of extracting and install go 1.24. The only problem is this old formula is trying to download go source code from google storage. In other words, the formula is pointing the go tar archive to an unreachable url. Edit the file /usr/local/Homebrew/Taps/homebrew/homebrew-local/Formula/go@1.24.rb. Change the checksums and URL to go.dev/de/go… And you’re good to go go.

Feels good to hack around homebrew formula :)