0

I wanted to make internally sharing/locally launching a shiny app developed with the {golem} framework a little more robust.

Hence, I used the renv package and installed the shiny app as a local package into a project folder.

I proceeded as follows (thanks @Kat for the suggestion):

  1. initialize renv using renv::init(bare = TRUE)

  2. renv::install("my_local_package")

  3. renv::snapshot(type = "all")

  4. renv::isolate()

  5. Writing a launch file consisting of:

library(golempackage)
renv::restore()
golempackage::run_app(options = list(launch.browser = TRUE))

  1. Share folder.

However, when launching the shiny app on a different computer (or a docker testing environment), I get the following error caused by the package bslib. Same happens when I delete my cache:

An error has occurred!

File attachments must exist: 'C:/Users/XYZ/AppData/Local/R/cache/R/renv/cache/v5/.../bslib/lib/bs3/assets/fonts'

Note: this error even occurs if I set the cache to be project-local and share it inside the project folder.

However, now the error message does not reference the global but the project-local cache. Unfortunately still as an absolute path which throws an error for other users.

This is all super weird and I have not the slightest idea why this occurs.

I would like to avoid removing bslib.

persephone
  • 380
  • 2
  • 10
  • 1
    You need to include `renv::isolate()` then `renv::restore()` so that there is no reliance on the cache, even when set to false. `isolate()` will set `settings$use.cache(FALSE)`, so you can remove that redundancy. – Kat Jan 03 '22 at 15:06
  • So the workflow would be: renv::init(bare = TRUE), renv::install("local package"), renv::isolate(), renv::restore()? I am using VScode instead of RStudio. Could this be causing problems too? – persephone Jan 03 '22 at 15:24

1 Answers1

0

As far as I can see, the error is coming from the sass package, e.g.

https://github.com/rstudio/sass/blob/f7a954027447dd0b9826ec01c7084c89a6e64fcc/R/layers.R#L442-L443

While I don't know exactly know what's going on, you could probably use the R debugger to check why that's failing. (Does the referenced folder exist in both cases? Are you expecting renv to be using the cache in the second case?)

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • Thanks, I will try to dig into it a bit more via debugging but it did not get me far so far. As for the latter point: perhaps the note was a bit vague. What I did here was not to isolate the project, but to set the cache to be project local and install the local package afterwards. – persephone Jan 05 '22 at 08:08
  • I just redid the second case: What is curious, though, is, that now the missing attatchment error references the "shared" cache folder inside the project folder - however, as an absolute path on my computer, making it impossible to share the folder – persephone Jan 05 '22 at 08:09