Skip to content

embed and deps when global cache not found #2178

@r2evans

Description

@r2evans

In the docs, I see "inspects the dependencies" and think that it will identify packages that are needed for that script. However, it seems to not do much in this case.

~/tmp/quux.R

library(data.table)
library(dplyr)
library(collapse)

data.table(a = pi) |>
  mutate(b = a * 2)
renv::embed("~/tmp/quux.R")
# [1] TRUE

This results in the following being prepended to the file.

renv::use(
  renv = "renv@1.1.4"
)

Given that renv otherwise can determine deps fairly easily with

renv::dependencies("~/tmp/quux.R")
# Finding R package dependencies ... Done!
#                 Source    Package Require Version   Dev
# 1 /Users/r2/tmp/quux.R   collapse                 FALSE
# 2 /Users/r2/tmp/quux.R data.table                 FALSE
# 3 /Users/r2/tmp/quux.R      dplyr                 FALSE
# 4 /Users/r2/tmp/quux.R       renv                 FALSE

I expected something like either of the following:

renv::use(
  renv = "renv@1.1.4",
  data.table = "data.table@1.17.8",
  dplyr = "dplyr@1.1.4",
  collapse = "collapse@2.1.2"
)
### or ###
renv::use(
  renv = "renv@1.1.4",
  data.table = "data.table",
  dplyr = "dplyr",
  collapse = "collapse"
)

Granted, it's not difficult for me to manually edit that portion of the file, but it seems like the utility/purpose of embed() is not working for me here. What am I missing and/or doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions