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

Restore must not fail during package installation #2077

Open
royfrancis opened this issue Jan 15, 2025 · 0 comments
Open

Restore must not fail during package installation #2077

royfrancis opened this issue Jan 15, 2025 · 0 comments

Comments

@royfrancis
Copy link

royfrancis commented Jan 15, 2025

From my experience, renv::restore() frequently fails for all sorts of different reasons related to installation issues with various packages. I don't think it should. If a package installation fails, it should keep track of that package and move on. At the end of restore, it should return a list of packages that failed to install. If not the default, this should at least be an option.

An even better option if installation fails, is that it should attempt to install the latest/current version of that package. Usually, I am fine with that as the exact version doesn't matter. Again this could be a user specified option.

My current solution to do this manually. Something like this using renv::install() is also not reliable:

for (i in 1:nrow(pkgdf)) {
  pkg <- pkgdf$Package[i]
  tryCatch(
    {
      if (!pkg %in% rownames(installed.packages())) renv::install(paste0(pkg,"@", pkgdf$Version[i]), prompt=FALSE)
    },
    error = function(e) {
      renv::install(pkg, prompt=FALSE)
    }
  )
}

So, I have switched to remotes and this seems to be more reliable.

for (i in 1:nrow(pkgdf)) {
  pkg <- pkgdf$Package[i]
  tryCatch(
    {
      if (!pkg %in% rownames(installed.packages())) remotes::install_version(pkg, version = pkgdf$Version[i], upgrade = "never")
    },
    error = function(e) {
      install.packages(pkg)
    }
  )
}

That was for CRAN/RSPM packages. Packages from bioconductor, github etc needs to be handled separately. I also miss out on caching. Is there a better way to do this? Am I missing something?

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

1 participant