Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Repository" entry to DESCRIPTION for better compatibility with renv? #850

Open
andrewheiss opened this issue Sep 12, 2023 · 3 comments
Labels
feature New feature or request

Comments

@andrewheiss
Copy link

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 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 library
renv::init()

# Add Stan's repo as a valid source
repos <- 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 lockfile
renv::snapshot()

# Make sure everything is good
renv::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 well
renv::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}.

@andrewheiss andrewheiss added the feature New feature or request label Sep 12, 2023
@jgabry
Copy link
Member

jgabry commented Sep 12, 2023

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.

@andrewheiss
Copy link
Author

Ok cool, I'll open a PR—thanks!

andrewheiss added a commit to andrewheiss/cmdstanr that referenced this issue Sep 12, 2023
@jgabry
Copy link
Member

jgabry commented Sep 13, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants