cole-brokamp / dep

Find, document, and deploy packages that an R project depends on
GNU General Public License v3.0
3 stars 1 forks source link

use something like this to only use private lib and not global lib?? #6

Open cole-brokamp opened 5 years ago

cole-brokamp commented 5 years ago

' Set your R library paths at run time

'

'

' A wrapper for .libPaths that removes .Library and .Library.site from your

' library paths while adding the contents of the character vector lib_vec.

'

' @title set_lib_paths

' @return nothing

' @export

set_lib_paths <- function(lib_vec) {

lib_vec <- normalizePath(lib_vec, mustWork = TRUE)

shim_fun <- .libPaths shim_env <- new.env(parent = environment(shim_fun)) shim_env$.Library <- character() shim_env$.Library.site <- character()

environment(shim_fun) <- shim_env shim_fun(lib_vec)

}

' Set your libPaths to .libPaths()[[1]]

'

' If you're using 'renv' this will hopefully remove your system libraries and give you an isolated environment.

'

' @title isolate_renv()

' @return nothing

' @export

isolate_renv <- function() {

paths <- .libPaths() set_lib_paths(paths[[1]])

}

cole-brokamp commented 5 years ago

global library still needs to be installed in order for R to find base packages that are installed with R. It doesn't seem like a good idea to duplicate these packages in the private library, but this also could present a problem if a user wants to install a specific version of a package in the private library when a different version of the package is installed in the global library.