Skip to content

Commit

Permalink
issue #66 set renv.config.pak.enabled = FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentGuyader committed Nov 6, 2023
1 parent adcaaf1 commit 63cd6e7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dockerfiler
Title: Easy Dockerfile Creation from R
Version: 0.2.1.9004
Version: 0.2.2
Authors@R: c(
person("Colin", "Fay", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0001-7343-1846")),
Expand Down Expand Up @@ -37,7 +37,7 @@ Suggests:
testthat (>= 3.0.0),
withr
VignetteBuilder: knitr
Config/fusen/version: 0.5.2.9000
Config/fusen/version: 0.5.1
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# dockerfile 0.2.x to 0.3.0
# dockerfile 0.2.2

- fix : create a `use_pak` parameters in `dock_from_renv` to set `renv.config.pak.enabled = FALSE` instead of `renv.config.pak.enabled = TRUE` to avoid issues with {pak} during `renv::restore()`

- feat: use of {memoise} to cache call to `pak::pkg_system_requirements`

Expand Down
5 changes: 4 additions & 1 deletion R/dock_from_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pkg_system_requirements_mem <- memoise::memoise(
#' @param renv_version character. The {renv} version to use in the generated Dockerfile.
#' By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a {renv} version, the version of {renv} bundled with {dockerfiler}, specifically `dockerfiler::renv$the$metadata$version`, will be used. If you set it to NULL, the latest available version of {renv} will be used.
#' @param use_pak boolean. If `TRUE` use {pak} to deal with dependencies during `renv::restore()`. FALSE by default
#' @importFrom utils getFromNamespace
#' @return A R6 object of class `Dockerfile`.
#' @details
Expand Down Expand Up @@ -65,6 +66,7 @@ dock_from_renv <- function(
repos = c(CRAN = "https://cran.rstudio.com/"),
expand = FALSE,
extra_sysreqs = NULL,
use_pak = FALSE,
renv_version
) {
distro <- match.arg(distro, available_distros)
Expand Down Expand Up @@ -256,7 +258,8 @@ dock_from_renv <- function(

dock$RUN(
sprintf(
"echo \"options(renv.config.pak.enabled = TRUE, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
"echo \"options(renv.config.pak.enabled = %s, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
use_pak,
repos_as_character
)
)
Expand Down
8 changes: 6 additions & 2 deletions dev/flat_dock_from_renv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pkg_system_requirements_mem <- memoise::memoise(
#' @param renv_version character. The {renv} version to use in the generated Dockerfile.
#' By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a {renv} version, the version of {renv} bundled with {dockerfiler}, specifically `dockerfiler::renv$the$metadata$version`, will be used. If you set it to NULL, the latest available version of {renv} will be used.
#' @param use_pak boolean. If `TRUE` use {pak} to deal with dependencies during `renv::restore()`. FALSE by default
#' @importFrom utils getFromNamespace
#' @return A R6 object of class `Dockerfile`.
#' @details
Expand Down Expand Up @@ -103,6 +104,7 @@ dock_from_renv <- function(
repos = c(CRAN = "https://cran.rstudio.com/"),
expand = FALSE,
extra_sysreqs = NULL,
use_pak = FALSE,
renv_version
) {
distro <- match.arg(distro, available_distros)
Expand Down Expand Up @@ -294,7 +296,8 @@ dock_from_renv <- function(
dock$RUN(
sprintf(
"echo \"options(renv.config.pak.enabled = TRUE, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
"echo \"options(renv.config.pak.enabled = %s, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
use_pak,
repos_as_character
)
)
Expand Down Expand Up @@ -364,6 +367,7 @@ writeLines(renv_file, file.path(dir_build, "renv.lock"))
# dock_from_renv ----
test_that("dock_from_renv works", {
# testthat::skip_on_cran()
# skip_if_not(interactive())
# Create Dockerfile
Expand Down Expand Up @@ -472,7 +476,7 @@ test_that("gen_base_image works", {
test_that("dock_from_renv works with specific renv", {
# testthat::skip_on_cran()
the_lockfile1.0.0 <- system.file("renv_with_1.0.0.lock",package = "dockerfiler")
for (lf in list(the_lockfile,the_lockfile1.0.0)){
Expand Down
3 changes: 3 additions & 0 deletions man/dock_from_renv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/testthat/test-dock_from_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ writeLines(renv_file, file.path(dir_build, "renv.lock"))

# dock_from_renv ----
test_that("dock_from_renv works", {
# testthat::skip_on_cran()
# skip_if_not(interactive())
# Create Dockerfile

Expand Down Expand Up @@ -141,7 +142,7 @@ test_that("gen_base_image works", {


test_that("dock_from_renv works with specific renv", {

# testthat::skip_on_cran()
the_lockfile1.0.0 <- system.file("renv_with_1.0.0.lock",package = "dockerfiler")

for (lf in list(the_lockfile,the_lockfile1.0.0)){
Expand Down

0 comments on commit 63cd6e7

Please sign in to comment.