Shiny server + renv

Currently looking to handling package dependencies in my shiny app using renv. I was wondering if there is a best practice for dealing with packages from development with shiny server production packages.

For example:
the Shiny server uses the global system library path to use packages. However renv's packages are stored in the renv directory.

Is it possible for either 1) the renv install the packages from the global system library or 2) somehow link the library that shiny server uses to the renv library

3 Likes

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

(Reopening this topic as it came to me through a support channel, and I think the answer is important for people to know)

By default, renv creates project libraries that cannot be moved to a different machine or even user account, due to its reliance on a global cache that sits outside of the project directory. This is exactly the behavior that you want if you're doing local development, but it is problematic for your scenario.

Fortunately, renv includes a solution for this problem. On the development machine, inside the project, call renv::isolate() and this will remove the reliance on the cache. You should then copy the entire project directory, including the project-specific .Rprofile, to the server.

Hope that helps.

3 Likes

Thanks @jcheng !
I came across this post trying to solve this exact problem, and your reply really helped.

Eventually what I did instead of actually copying the contents of the renv directory from the dev to prod server was to log into the production server, get into the app's directory. Then run R, and use renv::restore and then renv::isolate. I find it to be somewhat easier and hence preferable than copying directories from one location to the other.

3 Likes