Skip to content

R CMD check with docker rocker

Zhian N. Kamvar edited this page Nov 29, 2015 · 5 revisions

Introduction

From what I can tell, rocker is a docker container specifically for all things R. What is docker? Docker is basically a way of shipping and containing clean virtual environments to either deploy or test things on. Since it is a major pain in the ass to try and download R-devel on Mac, Windows, and even Linux, Docker is a neat solution. I had previously written up a gist on testing poppr with a the rocker r-devel container, and now I'm writing it here because it is ultimately useful for whomever decides to develop on poppr. Note that most of the heavy lifting was really done by Ted Hart and Carl Boettiger, I'm just applying what I got from them to poppr.

Step 1 - Install Docker:

This is relatively painless. You go to the docker website (I'm linking the mac version) and you follow the instructions.

Step 2 - start the docker...thing

Launch docker either through the command line or through the app. This basically just launches docker-machine and sets the environment variables. Since I have iTerm and don't like the OSX terminal popping up, I made an alias (in .bash_profile aka .bashrc for linux nerds) to the shell script that that application uses:

alias dock=". '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'";

So, now all I have to type is

dock

Step 3 - pull and enter the container.

UPDATE 2015-09-01

I have recently figured out how to actually make a container and host it. The container is located at https://hub.docker.com/r/zkamvar/poppr-devel-docker/ and it will update every time r-devel-san updates OR every time I push to https://github.com/zkamvar/poppr-devel-docker/.

All you have to do to get things going is:

cd /path/to/poppr

docker run --rm -ti -v $(pwd):/poppr zkamvar/poppr-devel-docker bash

Step 4 - Build and Check

One thing I didn't know is that apparently the development version of R is simply just RD:

RD CMD build --resave-data --no-manual --no-build-vignettes poppr; \
RD CMD check --as-cran poppr_*.tar.gz # specify the version number if you've build multiple times.

If this fails, check the latest build in https://hub.docker.com/r/zkamvar/poppr-devel-docker/builds/ and search the log for the word 'failed'. Reinstall any packages that failed to install in the proper place.

There will be warnings about memory leaks, but that comes from R itself. Don't worry about those (unless they specify a file that exists in poppr).

If you want to run all the tests using testthat within R, you can use

RD CMD INSTALL --install-tests poppr_*.tar.gz; \
RD -e 'library("poppr");library("testthat");Sys.setenv(NOT_CRAN = "true");test_package("poppr")'

Once you are done, you can exit your docker shell with:

exit