Upgrading to macOS Sierra (nee OSX) for R users

[This article was first published on R – Win-Vector Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A good fraction of R users use Apple computers. Apple machines historically have sat at a sweet spot of convenience, power, and utility:

  • Convenience: Apple machines are available at retail stores, come with purchasable support, and can run a lot of common commercial software.
  • Power: R packages such as parallel and Rcpp work better on top of a Posix environment.
  • Utility: OSX was good at interoperating with the Linux your big data systems are likely running on, and some R packages expect a native operating system supporting a Posix environment (which historically has not been a Microsoft Windows, strength despite claims to the contrary).

Frankly the trade-off is changing:

  • Apple is neglecting its computer hardware and operating system in favor of phones and watches. And (for claimed license prejudice reasons) the lauded OSX/macOS “Unix userland” is woefully out of date (try “bash --version” in an Apple Terminal; it is about 10 years out of date!).
  • Microsoft Windows Unix support is improving (Windows 10 bash is interesting, though R really can’t take advantage of that yet).
  • Linux hardware support is improving (though not fully there for laptops, modern trackpads, touch screens, or even some wireless networking).

Our current R platform remains Apple macOS. But our next purchase is likely a Linux laptop with the addition of a legal copy of Windows inside a virtual machine (for commercial software not available on Linux). It has been a while since Apple last “sparked joy” around here, and if Linux works out we may have a few Apple machines sitting on the curb with paper bags over their heads (Marie Kondo’s advice for humanely disposing of excess inanimate objects that “see”, such as unloved stuffed animals with eyes and laptops with cameras).

IMG 0726

That being said: how does one update an existing Apple machine to macOS Sierra and then restore enough functionality to resume working? Please read on for my notes on the process.

  • Why to upgrade:

    I won’t really go too deeply into why one would want to update to macOS Sierra. My reasons were vain hopes the “OSX spinny” would go away, and having to interoperate with Keynote users themselves running macOS Sierra (which has a different version of Keynote). I haven’t really noticed that many differences (I think Grab can now export PNG, the volume control can now send system sound to networked devices), and the upgrade was fairly painless. As expected the upgrade broke a lot of software I use to actually work. This is why I upgrade a scratch machine first. Searching around on the web I think I found enough fixes to restore functionality.

  • Why to not upgrade (or why to wait):

    Cran seems to still build and test packages for OSX Mavericks, so moving to macOS Sierra puts you further out of sync with the primary R repository. Also Homebrew (a source of non-decade out of date Posix/Unix software) is likely still catching up to macOS Sierra.

Below is our list of issues and work-arounds found in upgrading.

  1. ssh breaks.

    ssh is needed to log in to remote systems and to share Git source control data securely requires a user password each and every time use use it after the upgrade, even if you have put the control password in OSX’s keychain. The fix is to add a file called “config” to your “~/.ssh” directory with the following contents. Then after you unlock your ssh credential once (oddly enough by using the ssh password, not the keychain password) it should remain available to the operating system.

    Host *
       UseKeychain yes
       AddKeysToAgent yes
       IdentityFile ~/.ssh/id_rsa
    

    To add insult to injury the above config is not compatible with OS X El Capitan, so there is no config that works both before and after an operating system upgrade. Also, I have no good documentation on these features, I presume it is the “UseKeychain” argument doing all the work.

  2. Java breaks.

    A current Java is needed for some R packages (such as rJava and rSymPy). Fixing Java seems to take some combination of all of the steps cobbled together from here and here. You re-install Java 8 from Oracle. And then:

    # Fix Java Home in .profile or .bashrc, in my case add the line
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/
    # symlink a Java dynamic library, as some software looks the wrong place
    sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
    # Try to convince R where Java is
    sudo R CMD javareconf
    # Inside R re-install the rJava package
    install.packages("rJava",type='source')
    

    After that you may also want to fix “legacy Java 6” (it turns out I need it for my XML editor OxygenAuthor). That is just a matter of downloading and installing from https://support.apple.com/kb/dl1572 (despite it claiming not to be for Sierra).

  3. Homebrew breaks.

    Homebrew is one of the currently available ways to get somewhat up to date Unix/Posix software on a Mac. I think Homebrew is not yet officially supporting macOS Sierra, but some combination of the following seemed to bring it back (the sudo commands were all suggested by “brew doctor“, run at your own risk).

    brew doctor
    sudo chown -R $(whoami):admin /usr/local
    brew update
    sudo chown root:wheel /usr/local
    

The above seemed to be enough to get back in the game. I would suggest re-installing and testing complicated software environments such as VirtualBox, docker and Anaconda before upgrading too many machines.

To leave a comment for the author, please follow the link and comment on their blog: R – Win-Vector Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)