how to set up profiles in renv

how do i set up a profile for renv when i have a project template?

I am looking to install on init remote repos eg

Config/renv/profiles/myprofile/dependencies: rstudio/shiny, tidyverse/tidyverse

i dont quite follow this explanation in the vignette:

Profile-specific package dependencies can be declared within the project’s top-level DESCRIPTION file.

  • what does a DESC file for a project look like?
  • is there a full example somewhere of a DESC file and an renv init that I can see somewhere?

I tried looking in the unit tests of renv but those all write the DESC files within the context of the test temporarily.

Can you elaborate a bit more on what you're trying to accomplish?

The DESCRIPTION file just needs to be a "regular" DCF file, of the form Key: Value. The only thing renv cares about is whether the associated Config/renv/profiles entry exists.

You can "select" a particular profile by setting the RENV_PROFILE environment variable, or explicitly by using e.g. renv::activate(profile = "<profile>"). (This writes a file renv/profile containing the profile name, which is then read and used by new R sessions on startup -- basically a way of setting the "default" profile in a project)

i am creating projects from a template using the RS IDE. i have been initializing renv as part of the template, but renv is running into problems when a package is a repo and not a CRAN lib. I thought i could use a profile to tell renv that there are project deps that it needs to install on the init.

some followup questions:

  • where do i need to put the dcf?
  • does it have to be a specific name?
  • what else can go in that dcf other than Config/renv/...? (now i'm intrigued :slight_smile: )

are the steps?:

  1. create dcf file in the project root dir (called DESCRIPTION)
  2. append line to DESCRIPTION
  • Config/renv/profiles/myprofile/dependencies: rstudio/shiny, tidyverse/tidyverse
  1. renv:init(profile = 'myprofile')
  2. renv::activate(profile = 'myprofile')

after this the directory structure would be

  • root
    • .Rprofile
    • DESCRIPTION
    • renv

ah... it picks up the DESCRIPTION file on init, but has problems with remote repos

Config/renv/profiles/trial/dependencies: r-lib/devtools

* Initializing project ...
* Discovering package dependencies ... Done!
* Copying packages into the cache ... Done!
* Resolving missing dependencies  ... 
Installing progress [1.2.2] ...
	OK [linked cache]
The following package(s) were not installed successfully:

	[r]: package 'r' is not available

You may need to manually download and install these packages.

The following package(s) will be updated in the lockfile:

# CRAN ===============================
- askpass       [1.1 -> *]
- brew          [1.0-6 -> *]
- brio          [1.1.3 -> *]
- cachem        [1.0.6 -> *]
- callr         [3.7.0 -> *]
- commonmark    [1.7 -> *]
- credentials   [1.3.2 -> *]
- curl          [4.3.2 -> *]
- desc          [1.4.0 -> *]
- devtools      [2.4.3 -> *]
- diffobj       [0.3.5 -> *]
- evaluate      [0.14 -> *]
- fastmap       [1.1.0 -> *]
- fs            [1.5.2 -> *]
- gert          [1.5.0 -> *]
- gh            [1.3.0 -> *]
- gitcreds      [0.1.1 -> *]
- highr         [0.9 -> *]
- httr          [1.4.2 -> *]
- ini           [0.3.1 -> *]
- jsonlite      [1.7.2 -> *]
- knitr         [1.37 -> *]
- memoise       [2.0.1 -> *]
- mime          [0.12 -> *]
- openssl       [1.4.6 -> *]
- pkgbuild      [1.3.1 -> *]
- pkgload       [1.2.4 -> *]
- praise        [1.0.0 -> *]
- processx      [3.5.2 -> *]
- ps            [1.6.0 -> *]
- rappdirs      [0.3.3 -> *]
- rcmdcheck     [1.4.0 -> *]
- rematch2      [2.1.2 -> *]
- remotes       [2.4.2 -> *]
- roxygen2      [7.1.2 -> *]
- rprojroot     [2.0.2 -> *]
- rstudioapi    [0.13 -> *]
- rversions     [2.1.1 -> *]
- sessioninfo   [1.2.2 -> *]
- sys           [3.4 -> *]
- testthat      [3.1.1 -> *]
- usethis       [2.1.5 -> *]
- waldo         [0.3.1 -> *]
- whisker       [0.4 -> *]
- xfun          [0.29 -> *]
- xml2          [1.3.3 -> *]
- xopen         [1.0.0 -> *]
- yaml          [2.2.1 -> *]
- zip           [2.2.0 -> *]

* Lockfile written to 'C:/projects/newtest/renv/profiles/trial/renv.lock'.

Restarting R session...

* (trial) Project 'C:/projects/newtest' loaded. [renv 0.14.0]

it looks like it is not splitting on comma as is written in the comments in the script

I'll move this to an issue on the renv repo

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.