Add Slicer Nightly to Homebrew (macOS)

Hi all,

I am doing a fresh install of my OS and realized how powerful brew is. I checked whether I could install Slicer with it and discovered that only the stable version is available:

brew cask install slicer

I thought it would be convenient to be able to install the nightly build, so I took the liberty to submit a PR to homebrew-versions. I hope you’re ok with that. If it’s accepted, one could install the official nightly version on macOS by doing:

brew cask install slicer-nightly

This is the comitted cask:

It would need to be updated often. I can do it for some time, but I guess the right thing would be that someone from the core set a periodic script to update it everyday. It needs just the version (like 4.7.0.26186,672116) and an URL as parameters.

Please let me know what you think.

Best,
Fernando

3 Likes

Hi @Fernando

Thanks for working on this :+1:

As I have no experience with brew, do you have an example command line invocation of cask-repair ?

Would the following work:

curl -L https://raw.githubusercontent.com/vitorgalvao/tiny-scripts/master/cask-repair -o cash-repair.sh && \
chmod u+x cash-repair.sh && \ 
./cash-repair.sh --fail-on-error --cask-url XXX --cask-version 4.7.0.26186,672116  slicer

What should the parameter for cask-url and cask-version ?

1 Like

Hi @jcfr,

I learnt about all this stuff yesterday. I think something like that would work (replacing slicer by slicer-nightly). My idea is, once my PR is accepted, I can try those lines, make the necessary modifications, and once it seems like it’s working I’ll confirm the procedure in this thread.

Btw, the script doesn’t need to manually downloaded. It can be installed using brew:

brew install vitorgalvao/tiny-scripts/cask-repair
cask-repair --fail-on-error --cask-url XXX --cask-version 4.7.0.26186,672116 slicer-nightly

I’m not sure if the URL can be given as a function of the version, as in the cask code.

Sounds like a plan. Thanks :+1:

Thanks for the the note. (For the record, I naively downloaded the script on linux … but realized soon enough brew executable was required)

I have no idea. Keep us posted of your findings :smile:

This is the line for today (10 am UTC):

cask-repair --cask-version 4.7.0.26187,673138 slicer-nightly

The tool is clever enough to figure out the URL from the version and it automatically computes the SHA256. Also it created this pull request. Not bad.

Before running that line I had to go through the classic process of adding an ssh key to my computer and GitHub.

So one can now officially download and install 3D Slicer (and nightly) with brew. Shall we write something in the Announcements category? The wiki?

Do you think the above line could be run after each macOS build?

This is cool Fernando :ok_hand:

But what is the right install line?

I updated brew and but I get this:

$ brew cask install slicer-nightly
Error: Cask 'slicer-nightly' is unavailable: No Cask with this name exists.
Error: Install incomplete.

The same line works for regular slicer.

1 Like

I think you need to tell brew to look also in homebrew-versions. So, to configure:

  1. Install homebrew (I think this will install cask too)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Install homebrew-versions:
brew tap caskroom/versions

To install the first time:

brew cask install slicer-nightly

If you want to easily upgrade, you can install cask-upgrade:

brew tap buo/cask-upgrade

And each time you want to upgrade:

brew update
brew cu slicer-nightly

I think that these are more or less the steps that can be in the wiki / announcements.

Nice! Yes, step 2, adding the caskroom/versions is what I needed.

1 Like

Just curious - does Homebrew provide any statistics about package installs?

1 Like

The homebrew script downloads from midas, so our regular statistics will be updated by these installs.

2 Likes

Installing QT 4.8.7 with homebrew on mac 10.12:

  • brew tap cartr/qt4
  • brew tap-pin cartr/qt4
  • brew install qt@4
  • brew install qt-webkit@2.3

It would be nice to add these instructions to https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions/Prerequisites/Qt#Mac_2

Hans

Thanks @hjmjohnson - added:

https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions/Prerequisites/Qt#Mac_with_Homebrew

So, shall we discuss:

  1. Cron script to update the cask after each mac build
  2. Add the info to the wiki
  3. Announce this in the forum

Just updated the cask:

cask-repair --cask-version 4.7.0.26221,675049 slicer-nightly

Hi all,

I’m still not sure whether you think it’s useful to add this info to the wiki and/or the forum. Could you please give me some feedback?

I’ve kept updating the cask and it works very well. It’s nice to update Slicer with just one command.

Thanks

Hi Fernando,

Thanks for the reminder. I have been busy upgrading the infrastructure to work with Qt5 and VTK8 and didn’t have a chance to look further into this.

To move forward, it would be ideal to share few scripts consolidating all valuable information shared here.

For example:

  • script 1: slicer-homebrew-setuptenv.sh # This would allow to install the required homebrew environment
  • script 2: slicer-homebrew-update.sh # This script allowing to download the latest package, repackage and publish the PR for the cask, etc …

Last, since we all agree moving forward with this make sense :smile: (Thanks @Fernando for your patience and help), could you add the content of these scripts as well as few additional info on this wiki page:

https://www.slicer.org/wiki/Documentation/Labs/HomebrewCask

After we have the draft scripts ready and tested for few days, we will find them a home (e.g Slicer/Utilities/Scripts).

Alright! Those scripts would be run by you, right? I mean, we’re talking first about what you guys need to do to keep the cask updated and then we can publish the info needed by the users?

The script will be run automatically on a nightly basis from the macOS machine hosted at Kitware that is already generating the MacOSX installer.

Hopefully, running the scripts (with one or two arguments) is all that is needed.

The info (on the wiki to begin) will be high level documentation describing what is homebrew, when and how the cask are generated/updated/…

In this case, the users are Slicer maintainers or anyone who would like to run the scripts of their own

Sure, that is what I meant by “you” :smile:

Ok, but we’re doing this so that the end users can upgrade Slicer easily, right? Shall we write the instructions to the wiki page?

Indeed.

Instructions would be great. That said, they should be fairly minimum as all the steps would be captured in the scripts.

Ideally, running the setupenv script, and then running the update script should be the only things needed