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

feature request for implicit snapshot: allow a list packages to include in addition to automatic dependencies #1930

Open
torbjorn opened this issue Jun 21, 2024 · 4 comments

Comments

@torbjorn
Copy link

renv::snapshot() defaults to type="implicit"

This misses optional dependencies of my packages that are not listed.

One example is ggsave(...) with svglite. Using ggsave to save svg files is a fairly common use case (with us at least) However svglite is not a formal dependency of ggplot2. ggsave() just warns you that you cannot save svg files unless svgite is installed.

At this point this project can no longer use renv::snapshot(type="implicit") (ie the default snapshoting behavoiur). This will remove svglite. (Yes, I could just add it manually after the snapshot, and record it, but thats not how life is supposed to be).

Would it be possible to maintain a list of packages to include in addition to dependencies found by renv? (auto dependencies is, in my belief, still a nice feature to have access to. and its the default behaviour of much of renv after all)

Ideally this file could be DESCRIPTION, but I find that whenever I try to use a DESCRIPTION file in a project that is not an R package, I get other headaches.

@kevinushey
Copy link
Collaborator

The general escape hatch for these scenarios is to create a final called deps.R (or whatever name you prefer) and add things like library(svglite) so that renv can pick those dependencies up.

Alternatively, if this is something that renv could infer via static analysis, we could also infer a dependency on svglite if we certain types of ggsave() calls.

@torbjorn
Copy link
Author

An R source file deps.R whos sole purpose is to fix a deficiency/weakness elsewhere, sounds like something that should be a stop gap measure at best. Manually maintaining a list of known unspecified dependencies (like ggplot/svglite) also feels like something that will never scale well.

How about taking a stab at the source of the problem, the shortcomings of scanning source code for dependencies.

Currently package dependencies are controlled through two possible routes if I understand correctly:

  • Dynamic dependencies, from reading R source code with renv::dependencies
  • The DESCRIPTION file

How about introducing something analogous to the pyproject.toml file for poetry or requirements.txt?

So a third options could be just that:

  • A text file (or perhaps yaml or other config format) with dependencies (Though I see how this is actually really close to that deps.R text file)

@kevinushey
Copy link
Collaborator

449d41f could potentially help, assuming you're using "simple" calls of the form:

ggplot2::ggsave(filename = "path.svg")

with the file path used directly as a string in the call.

@torbjorn
Copy link
Author

torbjorn commented Jul 9, 2024

This would go some way to improving the automatic dependencies, but why not also introduce a formal way for developers to list their dependencies? The above can never be perfect and as the project grows chances are it will dyncamically create filenames and auto-depencies are out the window again.

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

No branches or pull requests

2 participants