The rapid pace of development for new packages and tools is both a blessing and a curse of the open source community. While great for testing new methodologies and taking advantage of cutting edge research, staying up to date at all times can quickly become a cumbersome chore.
A common question we get from new users is how to customize the version of R their projects use - either to a specific version or the most recent release. This is easy using Domino's custom compute environments, which allow you to specify which versions of which packages and programs you want your code and projects to run in.
Depending on the version of Domino you're using, you may have access to our newest iteration of managed environments (V2 environments): while we recommend using them if you're able, we'll cover both below.
Regardless of the environment version you use, the basics of how environments are constructed remain the same: you'll need a base image (usually stored on quay.io), and some Dockerfile commands to install the additional programs or packages on top of that base. While you can execute additional commands in the form of pre- and post-setup scripts, we'll stick to the basics for this example.
While you may have a custom base image for your deployment, we'll use the domino default for this example - as of this article it's the link below, but you should check here for a link to the most up to date base image.
Next, we'll need the command to replace the current R instillation. You can either chose a specific release (a list of versions can be found on CRAN):
RUN apt-get update -y
RUN apt-get remove r-base-core -y && apt-get install r-base-core=3.3.1* -y
or just use the most recent release:
RUN apt-get update -y
RUN apt-get remove r-base-core -y && apt-get install r-base-core -y
Next, we'll show you how to put this into an environment and test it out.
You can create a custom V1 environment by going to Settings > Hardware & Environment > Compute Environment, selecting Manage Environments, and then New Environment.
After giving your environment an easily recognizable name, you'll want to add the link to the docker base (as a FROM command) as well as the custom commands for upgrading R to the docker file. The completed environment should look like this:
Hit save, and you're done! To test, navigate back to your project, ensure it's set to use the environment you just created, and start up an interactive RStudio session. At the top of the terminal, you should see R is running the version you specified.
You can create a custom V2 environment by going to Settings > Hardware & Environment > Compute Environment, selecting Manage V2 Environments, and then New Environment. You'll be prompted to name and describe the environment you're building, after which you'll be able to edit the definition.
From here, you can either use your environment's base image or provide the quay.io link to a custom one.
Lastly, you'll add your custom RUN command for upgrading R to the Dockerfile instructions. Scroll to the bottom of the page and click Save.
That's it! Your completed environment should look like this:
V2 environments will start building themselves as soon as you save the definition. To view the build logs after saving, click on the revisions tab, select the version of the environment you want to inspect (the most recent one) and click on the build logs tab. You'll have to refresh this page as the build progresses, but from here you're able to track the progress of the build and diagnose any errors.
To test, navigate back to your project, ensure it's set to use the environment you just created, and start up an interactive RStudio session. At the top of the terminal, you should see R is running the version you specified.
If you run into any issues customizing your version of R or setting up custom environments, don't hesitate to reach out to email@example.com. For more details on what you can do with compute environments, check out the following resources:
Keywords: Updating R, Update R