You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It includes instructions for adding https://mc-stan.org/r-packages/ as a named repository for use with {renv}, either by using options(), or by manually adding an entry to renv.lock.
Since {renv} v1.0 (ish), having a second named repository in renv.lock triggers a "The project is out-of-sync" message even if the correct version of packages like {cmdstanr} are installed. See this issue at {renv} for more details, or see this reproducible example (starting from a new empty project):
# Start a new renv libraryrenv::init()
# Add Stan's repo as a valid sourcerepos<- c(Stan="https://mc-stan.org/r-packages/", CRAN="https://packagemanager.posit.co/cran/latest")
options(repos=repos)
# Install cmdstanr; it will come from the Stan repo; all other dependencies will come from CRAN/RSPM
install.packages("cmdstanr")
# Save to lockfilerenv::snapshot()
# Make sure everything is goodrenv::status()
#> No issues found -- the project is in a consistent state.# RESTART R SESSION#> Restarting R session...#> #> - Project '~/Desktop/renv-testing' loaded. [renv 1.0.2.9000; sha: dba0079]#> - The project is out-of-sync -- use `renv::status()` for details.# It says it's out of sync there ↑# But if I run renv::status() again, all is wellrenv::status()
#> No issues found -- the project is in a consistent state.
According to @kevinushey (rstudio/renv#1683 (comment)), this happens because even though https://mc-stan.org/r-packages/ is a named repository, {renv} checks for a "Repository" entry each package's DESCRIPTION file, and {cmdstanr} doesn't have that in its DESCRIPTION.
It's possible to fix this false positive warning by adding a "Repository" entry to DESCRIPTION:
Repository: Stan
It seems like a trivial enough change, but I don't know what the downstream consequences of doing that might be (so I'm opening an issue rather than making an actual pull request). The "Repository" entry isn't well documented so I don't know if it will mess things up, but it might be worth adding to non-CRAN packages like {cmdstanr} for better compatibility with {renv}.
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to our attention. If you're up for making a PR that would be great.
I'm 99% sure that adding this to DESCRIPTION won't interfere with anything (we'd just need to remember to remove it if we end up putting cmdstanr on CRAN), and that 1% doubt just comes from the fact that, like you said, this isn't really documented anywhere, so who really knows what would happen! But it would be good to not have false positive out of sync warnings when using cmdstanr with renv.
Just adding a note here pointing to @kevinushey's comments on the PR about handling this in a pre-build step, rather than adding to the DESCRIPTION file in the source code: #851 (comment)
Currently, the r-packages repository has a list of instructions for installing non-CRAN Stan packages like {cmdstanr} (see here for the live version).
It includes instructions for adding
https://mc-stan.org/r-packages/
as a named repository for use with {renv}, either by usingoptions()
, or by manually adding an entry torenv.lock
.Since {renv} v1.0 (ish), having a second named repository in
renv.lock
triggers a "The project is out-of-sync" message even if the correct version of packages like {cmdstanr} are installed. See this issue at {renv} for more details, or see this reproducible example (starting from a new empty project):According to @kevinushey (rstudio/renv#1683 (comment)), this happens because even though
https://mc-stan.org/r-packages/
is a named repository, {renv} checks for a "Repository" entry each package's DESCRIPTION file, and {cmdstanr} doesn't have that in its DESCRIPTION.It's possible to fix this false positive warning by adding a "Repository" entry to DESCRIPTION:
It seems like a trivial enough change, but I don't know what the downstream consequences of doing that might be (so I'm opening an issue rather than making an actual pull request). The "Repository" entry isn't well documented so I don't know if it will mess things up, but it might be worth adding to non-CRAN packages like {cmdstanr} for better compatibility with {renv}.
The text was updated successfully, but these errors were encountered: