⏱reading time: 4 min

As I just explained in my last post, the last version of R –3.4.4 “Someone to Lean on”– was rolled out las Thursday and this time I was the one that updated the Homebrew’s formula to reflect the new version. I just decided to give it a try and update for first time a Homebrew’s formula since no one had updated it yet on Thursday afternoon and this way I would be able to install the new version with Homebrew.

As I’ve already mentioned, I really encourage anyone to contribute to Homebrew’s community and try to keep the formulae update. Homebrew also encourage this, since as more people keep an eye on formula and update them, the better for the community.

How can you update a Homebrew formula?

The first and foremost important thing is to check if someone already filed a pull request for that same formulae, or in other words, if that formula is in the process of being updated. If no one is updating that formula, it’s opportunity to contribute and update it for the benefit of the community.

Before you begin, you need to update Homebrew to get the last version:

When you have the last version of Homebrew, you can edit your formula. If you just going to update the formula because there is a new version of the software that the formula installs, the best way to go is to use the script Homebrew provided to update formulae. In the case of R formula –r.rb– the syntax was as follows.

In this case, the URL and the sha256 was provided by Peter Dalgaard in the R 3.4.4 announcement. However, you have to take into account that https urls are preferred, so I had to recommit to follow that guidelines.

If you don’t have the sha256, you can calculate it yourself downloading the file and then running the following command that for me was as follows:

When you have those two parameters, you are ready to run the command. What the command does is basically create a fork of Homebrew in your account of Github, and then create a branch where it’s going to upload the modified formula. Then, it just makes a pull request to /homebrew-core.  If everything is ok, they’ll accept your changes and the new formula will be accessible to everyone after they run $ brew update. On the other hand, if you have to make modifications in the formula you are submitting in your pull request –as I needed to make– you just do them using Git.

Now, you can make the necessary changes and when you are done you just save the file and

If you want to test your version of the formula this is easy, you just stay in the branch where the modified formula is and run:

Updating R with Homebrew

Use someone else’s formula

You can even use this updated formula to update the R of someone computer while they accept your pull request –if you are in a hurry or you are antsy guy. To do so you can use hub.

Or you can directly install the formula that is their repo in GitHub:

In my case:

Or pull the formula from the pull request:

In my case:

However, I don’t recommend you to do something like this and install the someone’s formula unless you really know the person. You never know what it’s in the install script. Usually, pull request are resolved within hours and it’s much better practice to wait until the Homebrew maintainers review the updated formula and approve it.

One thought on “How I updated the R formula in Homebrew

Leave a Reply

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