# Add Slicer Nightly to Homebrew (macOS)

**URL:** https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811
**Category:** Development
**Created:** [August 2, 2017, 7:43pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811 "2017-08-02T19:43:17Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 2, 2017, 7:43pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/1 "2017-08-02T19:43:17Z")

</div>

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](https://github.com/caskroom/homebrew-cask/blob/d6da1a7be2ca37a53950ac7904ffb66b7facffef/Casks/slicer.rb):

```auto
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](https://github.com/caskroom/homebrew-versions/pull/4225) to [homebrew-versions](https://github.com/caskroom/homebrew-versions). I hope you’re ok with that. If it’s accepted, one could install the official nightly version on macOS by doing:

```auto
brew cask install slicer-nightly

```

This is the comitted `cask`:

> <https://github.com/fepegar/homebrew-versions/blob/c4a9537fdfa72081507ce4d56bed3c08c644844f/Casks/slicer-nightly.rb>

It would need to be [updated](https://github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md#updating-a-cask) 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](https://github.com/vitorgalvao/tiny-scripts/blob/master/cask-repair) 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

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 2, 2017, 8:01pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/2 "2017-08-02T20:01:39Z")

</div>

Hi @Fernando

Thanks for working on this 👍

As I have no experience with brew, do you have an example command line invocation of [cask-repair](https://github.com/vitorgalvao/tiny-scripts/blob/master/cask-repair) ?

Would the following work:

```auto
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` ?

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 2, 2017, 8:30pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/3 "2017-08-02T20:30:51Z")

</div>

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`:

```bash
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.

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 2, 2017, 8:48pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/4 "2017-08-02T20:48:09Z")

</div>

> [@Fernando](#):
>
> like it’s working I’ll confirm the procedure in this thread.

Sounds like a plan. Thanks 👍

> [@Fernando](#):
>
> doesn’t need to manually downloaded. It can be installed using brew

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

> [@Fernando](#):
>
> URL can be given as a function of the version

I have no idea. Keep us posted of your findings 😄

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 3, 2017, 10:18am UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/5 "2017-08-03T10:18:02Z")

</div>

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

```bash
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](https://github.com/caskroom/homebrew-versions/pull/4232). Not bad.

Before running that line I had to go through the classic process of [adding an ssh key to my computer and GitHub](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/).

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?

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [August 3, 2017, 12:08pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/6 "2017-08-03T12:08:34Z")

</div>

This is cool Fernando 👌

But what is the right install line?

I updated brew and but I get this:

```auto
$ 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.

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 3, 2017, 12:50pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/7 "2017-08-03T12:50:22Z")

</div>

> [@pieper](#):
>
> But what is the right install line?

I think you need to tell `brew` to look also in [`homebrew-versions`](https://github.com/caskroom/homebrew-versions). So, to configure:

1. Install `homebrew` (I think this will install `cask` too)

```auto
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

```

1. Install `homebrew-versions`:

```auto
brew tap caskroom/versions

```

To install the first time:

```auto
brew cask install slicer-nightly

```

If you want to easily upgrade, you can install [`cask-upgrade`](https://github.com/buo/homebrew-cask-upgrade):

```auto
brew tap buo/cask-upgrade

```

And each time you want to upgrade:

```auto
brew update
brew cu slicer-nightly

```

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

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [August 3, 2017, 1:32pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/8 "2017-08-03T13:32:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 3, 2017, 1:37pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/9 "2017-08-03T13:37:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [August 3, 2017, 1:55pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/10 "2017-08-03T13:55:14Z")

</div>

> [@fedorov](#):
>
> Just curious - does Homebrew provide any statistics about package installs?

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

---

<div class="post-metadata">

### Author: ![hjmjohnson](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hjmjohnson/32/173_2.png) [@hjmjohnson](https://discourse.slicer.org/u/hjmjohnson)
#### Post date: [August 4, 2017, 8:55pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/11 "2017-08-04T20:55:33Z")

</div>

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](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions/Prerequisites/Qt#Mac_2)

Hans

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [August 4, 2017, 11:40pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/12 "2017-08-04T23:40:52Z")

</div>

Thanks @hjmjohnson - added:

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build\_Instructions/Prerequisites/Qt#Mac\_with\_Homebrew](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions/Prerequisites/Qt#Mac_with_Homebrew)

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 5, 2017, 12:44pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/13 "2017-08-05T12:44:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 10, 2017, 10:18pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/14 "2017-08-10T22:18:56Z")

</div>

Just updated the cask:

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

```

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 15, 2017, 6:34pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/15 "2017-08-15T18:34:38Z")

</div>

> [@Fernando](#):
>
> 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

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

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 15, 2017, 6:46pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/16 "2017-08-15T18:46:24Z")

</div>

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 😄 (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](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`).

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 15, 2017, 7:34pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/17 "2017-08-15T19:34:34Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 15, 2017, 7:50pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/18 "2017-08-15T19:50:12Z")

</div>

> [@Fernando](#):
>
> Those scripts would be run by you, right?

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

> [@Fernando](#):
>
> what you guys need to do to keep the cask updated

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

> [@Fernando](#):
>
> then we can publish the info needed by the users?

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

---

<div class="post-metadata">

### Author: ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)
#### Post date: [August 15, 2017, 7:53pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/19 "2017-08-15T19:53:27Z")

</div>

> [@jcfr](#):
>
> the macOS machine hosted at Kitware

Sure, that is what I meant by “you” 😄

> [@jcfr](#):
>
> In this case, the users are Slicer maintainers

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?

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [August 15, 2017, 9:39pm UTC](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811/20 "2017-08-15T21:39:44Z")

</div>

> [@Fernando](#):
>
> 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

[Next page](https://discourse.slicer.org/t/add-slicer-nightly-to-homebrew-macos/811.md?page=2)
