Homebrew / homebrew-bundle

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.
MIT License
5.35k stars 287 forks source link

How to consider processor architecture when installing? #1229

Closed nhooey closed 1 year ago

nhooey commented 1 year ago

Sometimes it's necessary to know which app to install based on the system architecture:

Example from my own Ansible YAML: Which battery app to install:

  - name: zackelia/formulae/bclm             # Wrapper to read and write Battery Charge Level Max (BCLM) Run: sudo bclm write 80
    arch: x86_64
  - name: aldente                            # Prevents full battery charging on Apple Silicon
    arch: arm64

Is there a way to do this with homebrew-bundle?

colindean commented 1 year ago

Many if not most if not nearly all formulae and casks handle this. Homebrew Bundle just tells Homebrew what formulae and casks and whatnot to install. Those will then install the correct version for the architecture.

If you find this is not the case, double-check the formula/cask and then upstream to be sure that the software supports your architecture.

nhooey commented 1 year ago

In this case each app only supports a single architecture, and naively trying to install one on the wrong architecture will make Homebrew fail.

I'm not sure what will happen in homebrew-bundle's case.

But you could just evaluate the output of uname -m to make sure it's arm64 or x86_64, it seems.

jacobbednarz commented 1 year ago

as @colindean mentioned, this isn't something homebrew-bundle handles but offloads to the formula/cask. if you're seeing issues, the best place to investigate is the formula.

colindean commented 1 year ago

I see what you're trying to do now, sorry about that.

You can use Hardware::CPU.arm? and Hardware::CPU.intel? but n.b. these are not explicitly part of the Brewfile DSL so they're not guaranteed to work perpetually— they probably will for the foreseeable future.

I use this several of my own Brewfiles:

if OS.mac? && Hardware::CPU.arm?
  # OS-level dependency for pyodbc
  brew "unixodbc"
end

N.b. that the AlDente FAQ lists support for Intel Macs under the Is my MacBook Model supported? section and the DMG for v1.22 ships a universal binary.

MikeMcQuaid commented 1 year ago

You can use Hardware::CPU.arm? and Hardware::CPU.intel? but n.b. these are not explicitly part of the Brewfile DSL so they're not guaranteed to work perpetually— they probably will for the foreseeable future.

Yes, this is the best bet, I'd rely on this.