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

Allow separate "sources of truth" for R packages collected in deployment manifest #671

Closed
kevinushey opened this issue Feb 14, 2023 · 4 comments · Fixed by #791
Closed
Labels
dependencies 🐀 feature a feature request or enhancement
Milestone

Comments

@kevinushey
Copy link
Contributor

kevinushey commented Feb 14, 2023

Currently, rsconnect relies on Packrat for lockfile generation, which implies that package dependencies are always inferred based on what's currently installed or available in the user's R library.

However, users might reasonably want to be able to declare their project's package requirements in other ways. For example, they may want to:

  1. Override some package dependencies in a piecemeal way; e.g. use a different version on deployment, or install from a separate source,
  2. Read package dependencies from a separate "source of truth" altogether; e.g. renv.lock; pkg.lock; something else.

I believe part of (1) is supported on the Connect side with some side-channels for providing packages during a deployment, but (2) could be useful for users who want to be able to declaratively state what packages are to be used during deployment.

For an implementation sketch, I think we could have a function like askManifestType() that (if appropriate) would prompt the user for the "source of truth" for R packages, and then that could be passed as a parameter to deployApp(). There could also be a mechanism for setting these via R options / environment variables if it felt appropriate, or was asked for.

This request was from a professional customer, who would like more granular control over what packages are used and installed in deployments.

@hadley hadley added dependencies 🐀 feature a feature request or enhancement labels Feb 21, 2023
@hadley
Copy link
Member

hadley commented Mar 17, 2023

For 2, do you think we could just use a renv.lock/pkg.lock if present? Isn't presence of those files sufficient to indicate that you want to manage the versions yourself? (TBH I had always assumed this is what rsconnect did; I didn't realise that it always re-ran packrat, even if an existing lock file already existed)

@aronatkins
Copy link
Contributor

The historical reasons for running an rsconnect-time dependency scan:

  1. Folks weren't using tools like Packrat or renv.
  2. The target content (let's say R Markdown document) was part of a large project and required very few of its dependencies.
  3. No way to separate "development" from "production" dependencies (at the time).

Using an existing lock file is compelling, especially if this is a narrowly-scoped project and we can ignore unnecessary dependencies from information in that lock file.

If folks are deploying from a "kitchen sink" project, the cost to restore the environment at deploy-time will be fairly high.

The automatic scanning has simultaneously been convenient, surprising (especially for packages without explicit in-code dependencies), and inflexible.

@hadley
Copy link
Member

hadley commented Mar 17, 2023

FWIW we allow python users to make this decision with the forceGeneratePythonEnvironment argument.

@mdshw5
Copy link

mdshw5 commented Mar 20, 2023

I'd love the ability to specify my R dependencies via an renv lockfile during deployment to Posit Connect. The existing dependency discovery via packrat has caused headaches for our team in the past. We had also assumed that renv would be the preferred solution for an RStudio product. Thanks for continuing this discussion!

@hadley hadley added this to the 1.0.0 milestone Apr 27, 2023
hadley added a commit that referenced this issue May 8, 2023
Two main changes:

* Respect an renv lockfile, if present, rather than using the library.
* Capture dependencies directly with renv, rather than relying on the renv vendored inside of packrat.

Fixes #671. Fixes #809.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies 🐀 feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants