Install Unison 2.48.4 on Mac OS X with Homebrew

·

I use Unison to sync code between my local machine and my dev servers. To sync between two servers, it requires that the same version of Unison be installed on both servers.

Now, this isn’t usually a big deal, because once you get Unison set up, it’s set up. But, I usually get a bit frustrated when setting up a new development machine and ensuring that it has the same Unison version as my remote server.

Most recently, I needed to get Unison 2.48.4 on my local Mac so that it matched my remote server. BUT, homebrew didn’t support Unison 2.48.4.

So, after getting some feedback from one of my coworkers, we came up with the following. Maybe you’ll find it helpful.

# Get rid of existing Unison
brew uninstall --force unison

# Checkout version of homebrew with Unison 2.48.4
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52 Formula/unison.rb

# Install
brew install --force-bottle unison

# Set homebrew-core back to normal
git checkout master
git reset HEAD .
git checkout -- .

NOTE: If you get error: fatal: reference is not a tree: 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52 after running git checkout 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52 Formula/unison.rb, we’ve been able to fix the issue by recloning homebrew-core. If you get the same error, you’ll want to add these steps before retrying starting at the git checkout 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52 Formula/unison.rb command above.

cd /usr/local/Homebrew/Library/Taps/homebrew
rm -rf homebrew-core
git clone https://github.com/Homebrew/homebrew-core.git
cd homebrew-core

Comments

28 responses to “Install Unison 2.48.4 on Mac OS X with Homebrew”

  1. Osk Avatar

    This post has helped at least to automatticians to fix their unison environment. Thank you! It would have helped three probably, but I lost my faith in unison long ago.

  2. S.S Avatar

    Were there any additional commands that needed to be run after git checkout master command?

      1. Steven Stratis Avatar
        Steven Stratis

        Thanks for the reply. If I try to run git checkout 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52 Formula/unison.rb
        I’m getting the error: fatal: reference is not a tree: 05460e0bf3ae5f1a15ae40315940b2d39dd6ac52

        1. Eric Binnion Avatar

          What does it look like if you do the following commands in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core?

          • git status
          • git remote -v
          1. S.S Avatar

            Says that I’m up to date with master and that the remote origins are pointing to the github repo for fetch and push.

        2. Eric Binnion Avatar

          Hi Steven –

          Working with Jeff, who commented below, we were able to replicate the issue and come up with a fix. I’ve updated the post with some updated commands.

          Hope this helps.

  3. Julian Vidal Avatar

    Thanks Eric!

    FYI: My git checkout silently failed to overwrite the existing Formula/unison.rb file so I had to remove that before checking it out. If I didn’t, homebrew kept installing the latest version.

  4. Paul Harrison Avatar

    A less alarming way to fully clone homebrew-core is:

    cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

    git fetch –unshallow

  5. George Stephanis Avatar

    A couple enhancements I’ve found —

    export HOMEBREW_NO_INSTALL_CLEANUP=1 in my .bashrc file ensures that homebrew keeps the old versions of stuff around instead of deleting them.

    Also, brew uninstall --force unison can be swapped out for brew unlink unison — which will remove the unison alias but leave the other version in place so the old version can be installed.

    After this is all done, you should have two versions of the unison binary available, if you need to be able to connect to multiple servers running different unisons.

    … actually now that I think about it, the following may just work for everything:

    cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
    git fetch --unshallow
    brew list unison --versions
    brew switch unison 2.48.4_1

    After the brew list unison --versions the version 2.48 may be available again? If not then do the git checkout stuff above

  6. dukechem Avatar

    This comment also at https://gist.github.com/dukechem/ef5cb77d0b571eb0f794a4be821bd53c#gistcomment-3044805
    Example below shows general method to find and install commits for other older or newer versions of unison, in this case, 2.48.15 …
    It follows advice from https://medium.com/@schmijos/installing-old-homebrew-formulas-dc91de0c329c

    Note: this is ok for simple binary bottles, like unison, with few, if any, dependencies. But dependencies quickly break things if you try such tricks to try to have something like both python versions 3.69 and 3.74: pip3 breaks for example as shown at https://gist.github.com/dukechem in python.rb per comments at https://gist.github.com/dukechem/ef5cb77d0b571eb0f794a4be821bd53c

    cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

    git log master -- Formula/unison.rb
    ...
    commit f5755fe4ccecb63c669d633f804428267d3bf3d1
    Author: BrewTestBot <brew-test-bot@googlegroups.com>
    Date: Tue Feb 20 12:46:06 2018 +0000

    unison: update 2.48.15 bottle.

    $ brew unlink unison
    $ export HOMEBREW_NO_INSTALL_CLEANUP=1
    $ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f5755fe4ccecb63c669d633f804428267d3bf3d1/Formula/unison.rb
    ==> Consider using brew extract unison ...!
    This will extract your desired unison version to a stable tap instead of
    installing from an unstable URL!

    ######################################################################## 100.0%

    $ brew switch unison
    unison installed versions: 2.48.4_1, 2.48.15, 2.51.2
    “`

  7. Chris R Avatar

    Thank you for writing this up Eric! Worked a treat when I set up my new machine. ????

  8. John Avatar

    Thank you Eric! This is still relevant in 2020… ran into the ‘not a tree’ issue, and the workaround steps worked perfectly.

  9. leason Avatar

    Thank you, Eric. I’ve installed unison 2.48.4 on macOS 11.1 by your guide.

Leave a Reply to AlexisCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Eric Binnion

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from Eric Binnion

Subscribe now to keep reading and get access to the full archive.

Continue reading