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:

The internal packrat function identifyPackagesUsed is where most code scanning occurs. It would need to know about the ways that import adds package dependencies.

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


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.