RStudio Connect specify packages to load without using library()

I have been loading my packages via the import package to prevent clashes. But when I deploy an app or document to RStudio Connect, it seems to need me to specify packages via library() to know which packages to install.

Is there a way to specify required packages for an RStudio Connect deployment, without using library().

1 Like

Include a file dependencies.R with your application or document and include library(dependency) for each package dependency. That file is not loaded by your content, but its presence in the deployment is enough for rsconnect+packrat to list those packages as required.

The packrat package is responsible for identifying dependencies within your content; it does not know about the import package or how it adds packages.

It looks like someone recently filed an issue against packrat asking for import support: https://github.com/rstudio/packrat/issues/527

The internal packrat function identifyPackagesUsed is where most code scanning occurs. It would need to know about the ways that import adds package dependencies. https://github.com/rstudio/packrat/blob/505f12aa4ef884cc7021719f4f0e4b69a0b93354/R/dependencies.R#L401

Until the reference packrat issue is solved, the dependencies.R option is the most straightforward way to get your dependencies correctly enumerated. Unfortunately, it means declaring those references in two places.

CC @kevinushey

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.