Managing System Dependencies

I recently deployed one of my R-projects in a new Linux environment and had to go through the process of setting up the system so that all my code would run smoothly. I use renv to manage by R packages and I am really happy with this workflow. I did however encounter problems with system dependencies, requiring me to manually install stuff through the terminal.

I wanted to automate this process and therefore started researching how I could do this. From what I found there doesn't seem to be a "streamlined" way of doing this. I did however notice that on the intro page for renv it says at the bottom that future work for the renv package is using the sysreqsdb to validate and install system dependenciess. Having this functionality in renv would be really great for my workflow and I'm wondering if someone on this forum knows whenabouts this functionality would be implemented?

I understand that Rstudio has another paid service---the "Rstudio Package Manager"---which has this capability, and that development of the "renv" package might not be top priority.

1 Like

Neither renv nor Package Manager is necessarily going to help you with this automation, other than providing you with the information.

The public instance of RStudio Package Manager at may still be helpful to you, though. The reason is that the Package Manager will tell you what the bash commands are to install the prereqs you need for any package (or set of packages).

For example, the tidyverse page tells you to install the following sysreqs:

yum install -y libicu-devel
yum install -y make
yum install -y libcurl-devel
yum install -y openssl-devel
yum install -y epel-release
yum install -y pandoc
yum install -y libxml2-devel

(This is for CentOS 7, but you can select your operating system and get different instructions.)

1 Like

Thank you for the quick reply!

I did not know about the public instance of RStudio Package Manager, looks like a good resource. I think what I'll try to do is to use the API for the package manager together with the .lockfile renv produces to get a list of all the commands that will install the necessary system dependencies. Hopefully I can use this to create a script that new users can execute before using renv::restore() to install all the R packages for the project.

Thanks again!

1 Like

The RStudio Package Manager API has a system requirements endpoint.

I personally use the {containerit} package, which generates a Dockerfile with instructions for installing system requirements for all packages used in the project. I think it uses sysreqsdb. Then I let GitLab CI handle the rest.

Here's a demo and the output Dockerfile. It's automated the installation of annoying spatial libraries.

1 Like

Following the example in the server API guide I managed to get a response object from the Rstudio Package manager API which contains information about install scripts. I also managed to convert the response into a data frame where one column contains the dependencies install script.

I am wondering if there is a way to send a request to the server that makes it only return values for dependencies? Or if there is a way to filter the response before I turn it into a data frame? My knowledge about API's and the JSON format is limited so this question might be very basic.

Below is an example where create a data frame where one column contains the install scripts for system dependencies for the tidyverse package. Ideally I would like to specify in my request that I only want the system dependencies install scripts.

r  <- GET("")
r_content <- content(r)
r_data <, "text")))

Any help is appreciated!

Thanks for the advice!

I've never used dockerfiles before but they seem very handy. My impression is that I can use them to set up my workspace almost automatically on a new computer. I'll give your demo a try and see if dockerfiles are the way to go for my workflow!