How to Distribute Binaries for OS X Using Homebrew

  • > At least on OS X, things are a little easier with Homebrew.

    Absolutely. I adore Homebrew and it's ecosystem. Cask, in particular, is quite satisfying; gotta love installing a swath of neccessary fonts from the terminal. And, fwiw, the project is about to be on Homebrew, with no tap required: https://github.com/Homebrew/homebrew/pull/49040 Though getting it up was not quite as pain-free than our initial publishes to NPM.

    The thing is: Homebrew solves the problem for just a portion of your audience. In diff-so-fancy's case, we've supported Linux and Windows from the get-go, the only hard part is getting it installed. NPM solves that problem really well, and I can't imagine any other installation technique being our recommendation for Windows/Linux going forward.

  • You don't even need to maintain a separate custom tap repo. Keep the formula in the same repo in a Formula directory, and include the repo URL when tapping (gets rid of the homebrew- restriction)

    The brew command for users would be:

    brew tap octavore/delta https://github.com/octavore/delta.git

    brew install delta

    ---

    Example above of course doesn't currently work because the formula is not there

    (I successfully use it in my repo: https://github.com/stepanhruda/ios-simulator-app-installer)

  •     > when a post on better diffs showed up on Hacker News
        > last week ... people below are asking why a bash script
        > (that depends on a perl script) is being recommended to
        > install via NPM? [cont. about using Homebrew]
    
    This post is useful in general, but just to circle back on its motivation, for anyone wanting a non-npm (brew) install of the aforementioned diff tool (diff-so-fancy, not made by me) - I've a PR pending merge - Homebrew/homebrew#49040 [0].

    In the mean time, you can tap it:

        % brew tap OJFord/formulae
        % brew install diff-so-fancy
    
    
    [0](https://github.com/Homebrew/homebrew/pull/49040)

  • >Cross-platform app distribution is a hard problem! [...] At least on OS X, things are a little easier with Homebrew

    well.. yeah.. Every OS has an easy way to distribute binaries, the hard part is having something that work on each of them.

  • I've been forcefully switched to OS X recently because work, and overall it's been pretty great (I view it as a well-integrated UI over FreeBSD). A couple of things drive me nuts though:

    * (the window manager sucks, but that's not the topic. I had to get it out)

    * it needs a good package manager

    For us ol' bearded folk (at least spiritually), OS X comes with a slew of unix tools we love. It already includes both vim AND emacs! However, these tools are hopelessly outdated: Despite OS X 10.11 "El Capitan" coming out last fall, Vim is still 7.3 (that's from August 2010. 2010!), and Emacs 22 (2007. That's right.)

    So some enterprising folk come to the rescue: Fink, Homebrew, Macports...

    Homebrew installs over /usr, so come the next OS update, all that gets squashed. Macports installs into /opt/local, but somehow doesn't survive an OS update. Also, when I tried installing SciPy it went and recompiled GCC4 from source. Guys, the 90s called, and it's been shown that recompiling from source for each user isn't worth the effort.

    Apple gave MacPorts some support in the form of equipment, so there's some hints of their preferred method. But the core WTF is this: why doesn't OSX integrate a package manager for its unixy side?

  • Homebrew sucks on multi-user systems (especially if the Mac in question has previously been single-user) or after the Mac changes its owner/becomes a shared one (company laptop).

    Macports handles this usecase far, far better. Give your users sudo rights and be done. Only thing it desperately lacks is allowing third-party additional repositories like Debian's apt does.

  • I still use macports; what's the current state of opinion of homebrew vs. fink vs. macports?

  • Step 1 use pkgsrc . Not joyent's pkgsrc , but real pkgsrc . Step 2 see step 1.

  • You don’t even need to check the SHA256 by hand, just use `brew create <tarball URL>`. It’ll create a formula with a sensible name, fetch its URL, populate the SHA256, and open the file in your editor. However note it’ll create it in the core formula directory instead of your tap; you’ll need to move it yourself.

  • >Cross-platform app distribution is a hard problem!

    indeed, but couple of things

    specific to Mac OS X: there are homebrew, macports, fink and probably more

    distributing with homebrew to someone who already going with macports is problematic for example as it is advised to not have both installed.

    One alternative is to distribute a pkg and so use PackageMaker to build one.

    A pkg has the pros to be native to Apple, but the cons to not work for other systems like Windows and Linux.

    So here another alternative: Debian packages (deb).

    Wether with macports, homebrew or fink you can install the command line utility dpkg, and using dpkg-deb you can build deb supporting the darwin-amd64 arch.

    For Windows, you can use the utility wpkg, http://windowspackager.org/ and with it you can build deb packages for win32 and win64 architectures.

    Ultimately if you distribute command-line tools (not GUI app), you can use deb packages for Windows, Mac OS X and Linux Debian (Ubuntu etc.)

    Here an example (one of my tools that I need to distrib/install on servers): https://github.com/Corsaair/as3shebang/releases/tag/1.0.0

    Debian packages for everyone :)

    Linux and Mac OS X install: dpkg -i as3shebang_1.0.0_amd64.deb

    Windows install: wpkg -i as3shebang_1.0.0_win64.deb

    You can see the build scripts at the root of the repo, they are pretty similar.

    Also, once you have deb packages you can also convert them to rpm and other nix-like packages usinga tool like alien, see https://en.wikipedia.org/wiki/Alien_(software).

  • I guess you have to do this to avoid the name clash with Tigris's delta[0], which is the default if you do `brew install delta`? I'm not sure this is the best solution.

    [0] http://delta.tigris.org

  • I stumbled across this idea a few weeks ago to install some build software on an os x travis ci build machine (using OS X is the easiest way for travis ci to use a C++ compiler that isn't obsolete).

    Anyhow, it's nice and simple approach that works.

  • This is awesome. I was _just_ looking a few days ago for a good tutorial on how to distribute some bash scripts via homebrew and could not find a great resource. Thanks for the writeup.

  • Rate limit exceeded. http://archive.is/Zp8IQ works.

  • This is still quite a bit more work than publishing to npm:

    1. Jump to separate repository

    2. Create a .tar.gz with sensitive filename

    3. "upload somewhere"

    4. Manually update formula, sha, version

    4. Push

    Versus:

    1. npm bump && npm publish

    I ended up automating the formula updating after getting tired of doing that every other day, for a private tap.

  • Its a bit off topic but is there a good alternative for windows? chocolatey doesn't seem to be a good solution.

  • Interesting

  • I find OS X's package/dependency management system to be as cobbled together as Windows'.

    Linux got it right: https://en.wikipedia.org/wiki/Package_manager

    It drives me crazy that Apple removed one the most amazing features of *nix systems: a unified software repository. Brew/brew cask doesn't come close to AUR.