Installation to non-standard library path

Hi there,

I am trying to figure out a painless way for users to install an internal package in an environment where we have:

  • Only one place where a user has permission to write AND is stored between logins
  • The default package installation directory is locked down and packages can't be installed except by admin.

My current strategy is to get users to install packages to the one place we can (referred to as path_to_install_packages below). Can anyone a) help me understand any tradeoffs between using the withr approach versus the more base R approach and b) recommend/ points to strategies where others have wanted to share internal packages but have had to get creative where they were installed? Here is what I am doing right now:

path <- {path_to_install_packages}

## path is one of .libPaths()

## Set the environmental variable
Sys.setenv(R_LIBS = path)


Great - that works fine and the package can be called because path is one of them elements of libPaths(). Now here is the withr approach which is suggested by ?devtools::install():


with_libpaths(path, install()) 

This also works but is a little clunky because install() can't be run with devtools:: within with_libpaths. However it is attractive because it doesn't leave around a new environment variable.

Am I thinking about this wrong? How do other manage internal packages without access to any internet resources?

Thanks in advance