Homebrew tap when there is no artifact for the current OS

Let's say I have a formula like this:

class Foo < Formula
  desc "Foo desc..."
  homepage "https://foo.com"
  version "1.2.3"
  bottle :unneeded

  if OS.mac?
    url "https://foo.com/1.2.3/foo_macos_x86_64.tar.gz"
    sha256 "fake"
  end
  if OS.linux? && Hardware::CPU.intel?
    url "https://foo.com/1.2.3/foo_linux_x86_64.tar.gz"
    sha256 "fake"
  end

  def install
    bin.install "foo"
  end

  test do
    system "#{bin}/foo --version"
  end
end

This works fine on both macOS and Linux amd64, but if the user tries it on a Linux arm, for example, they'll get an error like:

formulae require at least a URL
Error: Cannot tap foo/foo: invalid syntax in tap!

Which is in fact what's happening, there is no URL for Linux Arm.

Is there a way to make this error better? Maybe somehow say which architectures and OSs are supported or something?


I am not overly familiar with Homebrew, but depends_on seems to allow you to specify an architecture. I think adding

depends_on arch: :x86_64

to your formula will solve the issue nicely.