Skip to content

Commit

Permalink
tweaks to extlib()
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Nov 13, 2018
1 parent 25461d3 commit 5b549b2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: packrat
Type: Package
Title: A Dependency Management System for Projects and their R Package
Dependencies
Version: 0.4.9-15
Version: 0.4.9-16
Author: Kevin Ushey, Jonathan McPherson, Joe Cheng, Aron Atkins, JJ Allaire
Maintainer: Kevin Ushey <[email protected]>
Description: Manage the R packages your project depends
Expand All @@ -21,4 +21,5 @@ Suggests:
rmarkdown
URL: https://github.com/rstudio/packrat/
BugReports: https://github.com/rstudio/packrat/issues
RoxygenNote: 6.1.0
RoxygenNote: 6.1.1
Encoding: UTF-8
18 changes: 14 additions & 4 deletions R/external.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,20 @@ with_extlib <- function(packages = NULL, expr, envir = parent.frame()) {
##' @rdname packrat-external
##' @export
extlib <- function(packages) {
lib.loc <- getDefaultLibPaths()
for (package in packages) {
library(package, character.only = TRUE, lib.loc = lib.loc)
}

# place user library at front of library paths (we want to
# include both the user library and the packrat library just
# so that external packaegs can still load and depend on
# packages only installed within the private library as well)
oldLibPaths <- .libPaths()
newLibPaths <- c(getDefaultLibPaths(), .libPaths())

.libPaths(newLibPaths)
on.exit(.libPaths(oldLibPaths), add = TRUE)

for (package in packages)
library(package, character.only = TRUE)

}

loadExternalPackages <- function() {
Expand Down
2 changes: 1 addition & 1 deletion inst/resources/init-rprofile.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#### -- Packrat Autoloader (version 0.4.9-15) -- ####
#### -- Packrat Autoloader (version 0.4.9-16) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####
2 changes: 1 addition & 1 deletion inst/resources/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ local({
## an 'installed from source' version

## -- InstallAgent -- ##
installAgent <- "InstallAgent: packrat 0.4.9-15"
installAgent <- "InstallAgent: packrat 0.4.9-16"

## -- InstallSource -- ##
installSource <- "InstallSource: source"
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
repo
packages/packrat
packrat/lib*/
1 change: 1 addition & 0 deletions tests/testthat/test-with_extlib.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
context("extlib without packages")

test_that("with_extlib successfully works with no packages provided", {
skip_on_cran()

## Make sure packrat mode is off
if (packrat:::isPackratModeOn())
Expand Down

0 comments on commit 5b549b2

Please sign in to comment.