Site icon R-bloggers

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:

Frankly the trade-off is changing:

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).

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.

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.