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

renv::install with explicit dependencies = Imports still installs Suggests #1336

Closed
Fuco1 opened this issue May 25, 2023 · 7 comments · Fixed by #1556
Closed

renv::install with explicit dependencies = Imports still installs Suggests #1336

Fuco1 opened this issue May 25, 2023 · 7 comments · Fixed by #1556
Labels
bug an unexpected problem or unintended behavior install 🧺

Comments

@Fuco1
Copy link

Fuco1 commented May 25, 2023

If I'm trying to install "active project", suggested packages get installed even when I explicitly only request Imports to be installed. The following code seems to be responsible:

  # if this is the DESCRIPTION file for the active project, include
  # Suggests since they're often needed as well. such packages will be
  # considered development dependencies, except for package projects
  type <- "unknown"
  project <-
    project %||%
    renv_dependencies_state(key = "root") %||%
    renv_project_resolve()

  if (renv_path_same(file.path(project, "DESCRIPTION"), path)) {

    # collect profile-specific dependencies as well
    profile <- renv_profile_get()
    field <- if (length(profile))
      sprintf("Config/renv/profiles/%s/dependencies", profile)

    fields <- c(fields, "Suggests", field)
    type <- renv_description_type(desc = dcf)

  }

Basically, now if I want to really only install Imports packages, I have to use some renv internals to generate a list of the dependencies and then filter out the "dev" dependencies (also I have to set Type in description to some bogus value so the type is not "package").

This behaviour is very unintuitive and is not documented anywhere in install. I think when user explicitly passes the dependencies parameter, nothing should happen to it and it should be taken as-is.

@hadley
Copy link
Member

hadley commented May 25, 2023

Can you please provide a reprex, or at least show exactly how you are running install()?

@Fuco1
Copy link
Author

Fuco1 commented May 25, 2023

Sorry, I should've been more precise. In a renv project, call renv::install("PATH_TO_PROJECT", dependencies = "Imports"). I'm not sure if path needs to be absolute or you can pass "." for current directory. I always use absolute path.

I don't know if this is normal, but I'm trying to install the project "to itself" as a dependency so that my analysis script can require itself instead of using devtools::load_all(). (the R/ contains all the logic and then I have a top-level file run.R which loads the package with library and does the analysis)

@hadley
Copy link
Member

hadley commented May 25, 2023

And presumably you have a DESCRIPTION file?

@hadley
Copy link
Member

hadley commented May 25, 2023

If so, this is a duplicate of #1019

@hadley hadley closed this as completed May 25, 2023
@kevinushey
Copy link
Collaborator

kevinushey commented May 25, 2023

I think this issue might be slightly different -- it sounds like the dependencies argument to install() is being ignored in this scenario? The other issue relates to what dependencies are installed by default?

@hadley
Copy link
Member

hadley commented May 25, 2023

@kevinushey good catch, I'll add a note to that issue.

@Fuco1
Copy link
Author

Fuco1 commented May 27, 2023

@kevinushey The argument is not ignored, but Suggests is appended to it as you see on this line fields <- c(fields, "Suggests", field).

@hadley Yes, I do. Sorry for not mentioning it. Here's a version with unrelated stuff removed

Package: Redacted
Title: Redacted
Version: 1.0.0
Authors@R:
    person(given = "Matúš",
           family = "Goljer",
           role = c("aut", "cre"),
           email = "matus.goljer@somewhere")
Description: Redacted
License: Redacted
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Depends:
    R (>= 4.3.0)
LinkingTo:
    Rcpp,
    testthat
Imports:
    AzureAuth,
    AzureStor,
    Rcpp
Suggests:
    testthat (>= 3.0.0),
    testthatBdd,
    devtools
Config/testthat/edition: 3

The idea is to have the "dev" dependencies in Suggests so when I'm creating a production docker image, I don't want those packages to be included (as you can imagine devtools, testthat, pkgdown etc are quite huuge and pull in a lot of dependencies)

@kevinushey kevinushey reopened this Jul 14, 2023
@kevinushey kevinushey added bug an unexpected problem or unintended behavior install 🧺 labels Jul 14, 2023
@kevinushey kevinushey added this to the 1.0.1 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior install 🧺
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants