... but not by default, and there are some hickups.
Development containers are awesome! They enable teams to work on a project, without the headaches of different package versions, formatter settings, ... you name it.
In R, there are some things we need to tune in order to arrive at usable devcontainers -- mainly to minimize setup times coming from R's package building defaults.
This repo showcases how to adjust all needed settings to work quickly.
there are some issues when working with pak and renv: r-lib/pak#325, rstudio/renv#1628. Until this is resolved, it's necessary to manually execute renv::restore() upon starting the devcontainer (instead of this being done in the background upon creation of the container).
I enjoy working with DevPod. There is a CLI-tool which can be installed according to the description. Once installed, create a ssh provider for example like so:
devpod provider add ssh --name <NAME> -o HOST=<USER>@HOST -o PORT=22 -o USE_BUILTIN_SSH=true -o INJECT_DOCKER_CREDENTIALS=true -o INJECT_GIT_CREDENTIALS=trueand start the devcontainer like so (for VScode):
devpod up git@github.com:juliopterix/r-devcontainer.git --ide vscodeor for positron:
devpod up git@github.com:juliopterix/r-devcontainer.git --ide positronThen, start a shell with R (or radian if you like) and execute
renv::restore()and
source("example_usage.R")I suggest you work with renv::install() instead of install.packages()
Some information for the future-savvy:
Using such a devcontainer (with a UNIX-distro as basis) allows us to install prebuilt R-packages.
This speeds up the setup times immensly: The Arrow R Package needs about 20 minutes to install with the default installation configuration.
With renv, pak and especially by setting the CRAN-repo option to options(repos = c(CRAN = "https://p3m.dev/cran/__linux__/noble/latest")), we arrive at a couple of minutes' installtion time for all packages in the lockfile (with arrow, and the tidyverse!). This is pure joy.