-
Notifications
You must be signed in to change notification settings - Fork 156
Description
I have, perhaps lazily, fallen into the habit of using renv:install(prompt = FALSE)
when packaging up shiny apps for deployment. This works great with base renv
as it goes through, finds, and installs all packages used in the directory. My reason for doing things this way is due to non-negotiable company anti-virus software, I can't actually use R when renv
is active as many package .dll
s get flagged. However, to "easily" deploy applications on our shiny server or test w/ Docker, renv
makes life easier. So, though I'm quite sure this not best practice, I have to refrain from using renv until development is complete and simply use it as a deployment tool.
Recently, I have seen a VAST difference in Docker build times and shiny server deployment when using options(renv.config.pak.enabled = TRUE)
and would like to go in that direction. However, I have noticed that renv:install(prompt = FALSE)
fails when pak
is enabled on a couple of different levels.
renv::deactivate(clean = TRUE)
# restart R
renv::activate()
# restart R
renv::install(prompt = FALSE)
Firstly, I am prompted whether I want to install pak
or not. This is not a huge deal but does not agree with the prompt = FALSE
argument.
The following package(s) will be installed:
- pak [0.7.2]
These packages will be installed into "~/path/to/app/renv/library/macos/R-4.4/x86_64-apple-darwin20".
Do you want to proceed? [Y/n]:
Secondly, and more importantly, I get this error which I presume is just the way pak
is set up to work:
# Installing packages ----------------------------------------
- Installing pak ... OK [linked from cache]
Successfully installed 1 package in 23 milliseconds.
Error:
! error in pak subprocess
Caused by error in `find_package_root(path = root)`:
! Could not find R package in `/path/to/app` or its parent directories.
Type .Last.error to see the more details.
Traceback (most recent calls last):
6: renv::install(prompt = FALSE)
5: renv_pak_install(packages, libpaths, project)
4: pak$local_install_dev_deps(root = project, lib = lib)
3: remote(function(...) {
get("local_install_dev_deps_make_plan", asNamespace("pak"))(...)
}, list(root = root, lib = lib, upgrade = upgrade, start = start,
dependencies = dependencies, loaded = loaded_packages(lib)))
2: err$throw(res$error)
1: base::stop(cond)
However, if I:
renv::dependencies() |>
getElement("Package") |>
unique() |>
renv::install(prompt = FALSE)
I'm still prompted:
Finding R package dependencies ... Done!
→ Will update 1 package.
→ The package (103.96 kB) is cached.
+ KernSmooth 2.23-22 → 2.23-24
? Do you want to continue (Y/n)
But then things work after I Y
:
ℹ No downloads are needed, 1 pkg (103.96 kB) is cached
✔ Got KernSmooth 2.23-24 (x86_64-apple-darwin20) (104.06 kB)
✔ Installed KernSmooth 2.23-24 (62ms)
✔ 19 pkgs + 93 deps: kept 111, upd 1, dld 1 (104.06 kB) [40s]
After which point I renv::snapshot()
.
However, if I simply renv::activate()
, restart, and then renv::snapshot()
, that seems to find and install packages just fine using the prompts hence the issue.