Skip to content

Commit eef7dcb

Browse files
committed
make all uses of with_libpaths use action="prefix", needed on linux
1 parent 6d8ee8c commit eef7dcb

5 files changed

Lines changed: 46 additions & 44 deletions

File tree

.github/workflows/test-all.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Package Dependencies
2323
run: R -q -e 'remotes::install_deps("nCompiler", dependencies=TRUE)'
2424
- name: Install inline
25-
run: R -q -e 'remotes::install_cran("inline", "nimble")'
25+
run: R -q -e 'remotes::install_cran(c("inline", "nimble"))'
2626
- name: Build Package
2727
run: |
2828
R CMD build nCompiler

nCompiler/R/nCompile.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,13 @@ nCompile <- function(...,
414414
pkgDir <- file.path(dir, temppkgname)
415415
# cat("about to try devtools::install\n")
416416
ans <- try({
417-
withr::with_libpaths(lib, {
417+
withr::with_libpaths(lib, action="prefix", code = {
418418
devtools::install(pkgDir,
419419
quick = TRUE,
420420
quiet = !isTRUE(get_nOption("showCompilerOutput")),
421421
upgrade = "never") # Make quiet follow showCompilerOutput
422-
withr::with_libpaths(lib, loadNamespace(temppkgname))
422+
withr::with_libpaths(lib, action="prefix",
423+
code = loadNamespace(temppkgname))
423424
})
424425
pkgEnv <- getNamespace(temppkgname)
425426
ans_ <- lapply(returnNames, function(x) {

nCompiler/R/packaging.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ erasePackage <- function(pkgName, dir = '.',
165165
if(is_installed) devtools::uninstall(pkgName, quiet = quiet)
166166
} else {
167167
is_installed <- any(grepl(pkgNamed, installed.packages(lib.loc = lib)))
168-
if(is_installed) withr::with_libpaths(lib, devtools::uninstall(pkgName, quiet = quiet))
168+
if(is_installed) withr::with_libpaths(lib, action="prefix",
169+
code = devtools::uninstall(pkgName, quiet = quiet))
169170
#remove.packages(pkgName)
170171
}
171172
}

nCompiler/tests/testthat/nCompile_tests/test-argumentPassing.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ test_that("pass 1D by ref and blockRef works and error-traps (compiled & uncompi
104104
test <- writePackage(foo, pkgName = "testpackage", dir = dir, modify="clear")
105105
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
106106
dir.create(lib, showWarnings=FALSE)
107-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
107+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
108108
upgrade = "never", quick=TRUE, quiet=TRUE))
109-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
109+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
110110
test_foo(access_dynamic_package("testpackage", "foo"))
111111
test_foo(access_dynamic_package("testpackage", "foo"))
112112
})
@@ -161,9 +161,9 @@ test_that("pass 1D by ref and blockRef works and error-traps via nClass method (
161161
test <- writePackage(nc1, pkgName = "testpackage", dir = dir, modify="clear")
162162
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
163163
dir.create(lib, showWarnings=FALSE)
164-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
164+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
165165
upgrade = "never", quick=TRUE, quiet=TRUE))
166-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
166+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
167167
Cobj <- access_dynamic_package("testpackage", "nc1")$new()
168168
test_foo(Cobj$foo)
169169
CppObj <- Cobj$private$CppObj
@@ -215,9 +215,9 @@ test_that("pass 2D by ref and blockRef works and error-traps (compiled & uncompi
215215
test <- writePackage(foo, pkgName = "testpackage", dir = dir, modify="clear")
216216
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
217217
dir.create(lib, showWarnings=FALSE)
218-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
218+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
219219
upgrade = "never", quick=TRUE, quiet=TRUE))
220-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
220+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
221221
test_foo(testpackage::foo)
222222
test_foo(testpackage::foo)
223223
})
@@ -277,9 +277,9 @@ test_that("pass 2D by ref and blockRef works and error-traps via nClass method (
277277
test <- writePackage(nc1, pkgName = "testpackage", dir = dir, modify="clear")
278278
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
279279
dir.create(lib, showWarnings=FALSE)
280-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
280+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
281281
upgrade = "never", quick=TRUE, quiet=TRUE))
282-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
282+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
283283
Cobj <- testpackage::nc1$new()
284284
test_foo(Cobj$foo)
285285
CppObj <- Cobj$private$CppObj
@@ -331,9 +331,9 @@ test_that("pass 3D by ref and blockRef works and error-traps (compiled & uncompi
331331
test <- writePackage(foo, pkgName = "testpackage", dir = dir, modify="clear")
332332
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
333333
dir.create(lib, showWarnings=FALSE)
334-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
334+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
335335
upgrade = "never", quick=TRUE, quiet=TRUE))
336-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
336+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
337337
test_foo(testpackage::foo)
338338
test_foo(testpackage::foo)
339339
})
@@ -394,9 +394,9 @@ test_that("pass 2D by ref and blockRef works and error-traps via nClass method (
394394
test <- writePackage(nc1, pkgName = "testpackage", dir = dir, modify="clear")
395395
lib <- file.path(tempdir(), "test_nComp_lib_argPassing")
396396
dir.create(lib, showWarnings=FALSE)
397-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
397+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
398398
upgrade = "never", quick=TRUE, quiet=TRUE))
399-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
399+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
400400
Cobj <- testpackage::nc1$new()
401401
test_foo(Cobj$foo)
402402
CppObj <- Cobj$private$CppObj

nCompiler/tests/testthat/nCompile_tests/test-nCompile.R

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ test_that("nCompile direct, package, and writePackage work with Eigen::Tensors",
6060
test <- writePackage(add_vectors, pkgName = "testpackage", dir = dir, modify="clear")
6161
lib <- file.path(tempdir(), "test_nComp_lib")
6262
dir.create(lib, showWarnings=FALSE)
63-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
63+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
6464
upgrade = "never", quick=TRUE, quiet=TRUE))
65-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
65+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
6666
expect_equal(x1+x2, access_dynamic_package("testpackage", "add_vectors")(x1, x2)) # testpackage::add_vectors(x1, x2))
6767
pkgload::unload("testpackage")
6868
})
@@ -110,9 +110,9 @@ test_that("nCompile direct, package, and writePackage work with nClass interface
110110
test <- writePackage(nc, pkgName = "testpackage", dir = dir, modify="clear")
111111
lib <- file.path(tempdir(), "test_nComp_lib")
112112
dir.create(lib, showWarnings=FALSE)
113-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
113+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
114114
upgrade = "never", quick=TRUE, quiet=TRUE))
115-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
115+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
116116
obj <- access_dynamic_package("testpackage", "nc")$new() #testpackage::nc$new()
117117
expect_equal(x1 + x2, obj$add_vectors(x1, x2))
118118
CppObj <- obj$private$CppObj
@@ -123,9 +123,9 @@ test_that("nCompile direct, package, and writePackage work with nClass interface
123123
test <- writePackage(nc, pkgName = "testpackage", interfaces = "generic", dir = dir, modify="clear")
124124
lib <- file.path(tempdir(), "test_nComp_lib")
125125
dir.create(lib, showWarnings=FALSE)
126-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
126+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
127127
upgrade = "never", quick=TRUE, quiet=TRUE))
128-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
128+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
129129
CppObj <- access_dynamic_package("testpackage", "nc")() # testpackage::nc()
130130
expect_equal(x1 + x2, method(CppObj, 'add_vectors')(x1, x2))
131131
obj <- to_full_interface(CppObj)
@@ -183,9 +183,9 @@ test_that("nCompile direct, package, and writePackage work with various name man
183183
test <- writePackage(add.Scalars, pkgName = "testpackage", dir = dir, modify="clear")
184184
lib <- file.path(tempdir(), "test_nComp_lib")
185185
dir.create(lib, showWarnings=FALSE)
186-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
186+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
187187
upgrade = "never", quick=TRUE, quiet=TRUE))
188-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
188+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
189189
expect_equal(access_dynamic_package("testpackage", "add.Scalars")(2, 3), 5) #testpackage::add.Scalars(2, 3), 5)
190190
pkgload::unload("testpackage")
191191

@@ -198,9 +198,9 @@ test_that("nCompile direct, package, and writePackage work with various name man
198198
test <- writePackage(add.Scalars_name, pkgName = "testpackage", dir = dir, modify="clear")
199199
lib <- file.path(tempdir(), "test_nComp_lib")
200200
dir.create(lib, showWarnings=FALSE)
201-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
201+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
202202
upgrade = "never", quick=TRUE, quiet=TRUE))
203-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
203+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
204204
expect_equal(access_dynamic_package("testpackage", "add.Scalars_name")(2, 3), 5) #testpackage::add.Scalars_name(2, 3), 5)
205205
pkgload::unload("testpackage")
206206

@@ -213,9 +213,9 @@ test_that("nCompile direct, package, and writePackage work with various name man
213213
test <- writePackage(add.Scalars_eName, pkgName = "testpackage", dir = dir, modify="clear")
214214
lib <- file.path(tempdir(), "test_nComp_lib")
215215
dir.create(lib, showWarnings=FALSE)
216-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
216+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
217217
upgrade = "never", quick=TRUE, quiet=TRUE))
218-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
218+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
219219
expect_equal(access_dynamic_package("testpackage", "foo1")(2, 3), 5) #testpackage::foo1(2, 3), 5)
220220
pkgload::unload("testpackage")
221221

@@ -228,9 +228,9 @@ test_that("nCompile direct, package, and writePackage work with various name man
228228
test <- writePackage(add.Scalars_name_eName, pkgName = "testpackage", dir = dir, modify="clear")
229229
lib <- file.path(tempdir(), "test_nComp_lib")
230230
dir.create(lib, showWarnings=FALSE)
231-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
231+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
232232
upgrade = "never", quick=TRUE, quiet=TRUE))
233-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
233+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
234234
expect_equal(access_dynamic_package("testpackage", "foo2")(2, 3), 5) # testpackage::foo2(2, 3), 5)
235235
pkgload::unload("testpackage")
236236
})
@@ -329,9 +329,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
329329
test <- writePackage(nc, interfaces = "generic", pkgName = "testpackage", dir = dir, modify="clear")
330330
lib <- file.path(tempdir(), "test_nComp_lib2")
331331
dir.create(lib, showWarnings=FALSE)
332-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
332+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
333333
upgrade = "never", quick=TRUE, quiet=TRUE))
334-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
334+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
335335
obj <- access_dynamic_package("testpackage", "nc")(); test_obj(obj)
336336
objf <- to_full_interface(obj); test_obj(objf)
337337
rm(obj, objf); gc(); pkgload::unload("testpackage")
@@ -342,9 +342,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
342342
test <- writePackage(nc, pkgName = "testpackage", dir = dir, modify="clear")
343343
lib <- file.path(tempdir(), "test_nComp_lib2")
344344
dir.create(lib, showWarnings=FALSE)
345-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
345+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
346346
upgrade = "never", quick=TRUE, quiet=TRUE))
347-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
347+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
348348
obj <- access_dynamic_package("testpackage", "nc")$new(); test_obj(obj)
349349
objC <- obj$private$CppObj; test_obj(objC)
350350
rm(obj, objC); gc()
@@ -380,9 +380,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
380380
test <- writePackage(nc_name, interfaces = "generic", pkgName = "testpackage", dir = dir, modify="clear")
381381
lib <- file.path(tempdir(), "test_nComp_lib2")
382382
dir.create(lib, showWarnings=FALSE)
383-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
383+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
384384
upgrade = "never", quick=TRUE, quiet=TRUE))
385-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
385+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
386386
obj <- access_dynamic_package("testpackage", "nc_name")(); test_obj(obj)
387387
objf <- to_full_interface(obj); test_obj(objf)
388388
rm(obj, objf); gc(); pkgload::unload("testpackage")
@@ -393,9 +393,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
393393
test <- writePackage(nc_name, pkgName = "testpackage", dir = dir, modify="clear")
394394
lib <- file.path(tempdir(), "test_nComp_lib2")
395395
dir.create(lib, showWarnings=FALSE)
396-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
396+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
397397
upgrade = "never", quick=TRUE, quiet=TRUE))
398-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
398+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
399399
obj <- access_dynamic_package("testpackage", "nc_name")$new(); test_obj(obj)
400400
objC <- obj$private$CppObj; test_obj(objC)
401401
rm(obj, objC); gc(); pkgload::unload("testpackage")
@@ -432,9 +432,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
432432
test <- writePackage(nc_eName, interfaces = "generic", pkgName = "testpackage", dir = dir, modify="clear")
433433
lib <- file.path(tempdir(), "test_nComp_lib2")
434434
dir.create(lib, showWarnings=FALSE)
435-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
435+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
436436
upgrade = "never", quick=TRUE, quiet=TRUE))
437-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
437+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
438438
obj <- access_dynamic_package("testpackage", "exnc1")(); test_obj(obj)
439439
objf <- to_full_interface(obj); test_obj(objf)
440440
rm(obj, objf); gc(); pkgload::unload("testpackage")
@@ -445,9 +445,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
445445
test <- writePackage(nc_eName, pkgName = "testpackage", dir = dir, modify="clear")
446446
lib <- file.path(tempdir(), "test_nComp_lib2")
447447
dir.create(lib, showWarnings=FALSE)
448-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
448+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
449449
upgrade = "never", quick=TRUE, quiet=TRUE))
450-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
450+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
451451
obj <- access_dynamic_package("testpackage", "exnc1")$new(); test_obj(obj)
452452
objC <- obj$private$CppObj; test_obj(objC)
453453
rm(obj, objC); gc(); pkgload::unload("testpackage")
@@ -483,9 +483,9 @@ test_that("nCompile works for nClass with classname and/or exportName and either
483483
test <- writePackage(nc_name_eName, interfaces = "generic", pkgName = "testpackage", dir = dir, modify="clear")
484484
lib <- file.path(tempdir(), "test_nComp_lib2")
485485
dir.create(lib, showWarnings=FALSE)
486-
withr::with_libpaths(lib, devtools::install(file.path(dir, "testpackage"),
486+
withr::with_libpaths(lib, action = "prefix", code = devtools::install(file.path(dir, "testpackage"),
487487
upgrade = "never", quick=TRUE, quiet=TRUE))
488-
withr::with_libpaths(lib, load_dynamic_namespace("testpackage"))
488+
withr::with_libpaths(lib, action = "prefix", code = load_dynamic_namespace("testpackage"))
489489
obj <- access_dynamic_package("testpackage", "exnc2")(); test_obj(obj)
490490
objf <- to_full_interface(obj); test_obj(objf)
491491
rm(obj, objf); gc(); pkgload::unload("testpackage")

0 commit comments

Comments
 (0)