Why does `renv` do not restore packages which are deprecated for a older R versions?

992 views Asked by At

I have the following setup:

  • I initialized a new R-Project (R 3.4.3) from a git repo.
  • The project from the repo used renv(0.11.0) to snapshot the project packages
  • The renv.lock file contains multiple packages. One of them is raster with version 2.9-5

Since the newer versions of the raster package on CRAN changed the R dependencies (R>= 3.5), renv can not restore the package because renv does not find the raster package on CRAN any more.

Message:

Error: package 'raster' is not available

The project on the git repo was built with R version 3.4.3. I do use a local repo for this project as well but this does not cause problems at all.

Any suggestions to get renv working as intended?

2

There are 2 answers

2
Kevin Ushey On

This seems to work for me with renv 0.12.0. Using this lockfile:

{
  "R": {
    "Version": "3.4.4",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cran.rstudio.com"
      }
    ]
  },
  "Packages": {
    "Rcpp": {
      "Package": "Rcpp",
      "Version": "1.0.5",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "125dc7a0ed375eb68c0ce533b48d291f"
    },
    "lattice": {
      "Package": "lattice",
      "Version": "0.20-35",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "10a22a9a66fbe7944e9ef98985d7c927"
    },
    "raster": {
      "Package": "raster",
      "Version": "2.9-5",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "85a01c2f0ad30d43f51b861a2d78d5e8"
    },
    "renv": {
      "Package": "renv",
      "Version": "0.12.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "7340c71f46a0fd16506cfa804e224e44"
    },
    "sp": {
      "Package": "sp",
      "Version": "1.4-4",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "e0485290545c0e768c2b50390114da1f"
    }
  }
}

I see the following on renv::restore():

> renv::restore()
The following package(s) will be updated:

# CRAN ===============================
- Rcpp     [* -> 1.0.5]
- raster   [* -> 2.9-5]
- sp       [* -> 1.4-4]

Do you want to proceed? [y/N]: y
* Querying repositories for available binary packages ... Done!
* Querying repositories for available source packages ... Done!
Retrieving 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.5.tar.gz' ...
        OK [file is up to date]
Retrieving 'https://cran.rstudio.com/src/contrib/Archive/raster/raster_2.9-5.tar.gz' ...
        OK [file is up to date]
Retrieving 'https://cran.rstudio.com/src/contrib/sp_1.4-4.tar.gz' ...
        OK [file is up to date]
Installing Rcpp [1.0.5] ...
        OK [built from source]
Installing sp [1.4-4] ...
        OK [built from source]
Installing raster [2.9-5] ...
        OK [built from source]

If you're still having issues even after updating to renv 0.12.0, I would recommend filing an issue with some extra context at https://github.com/rstudio/renv/issues.

0
Freakazoid On

The suggestions did not work for me. But I solved the issue by ignoring the cache from renv. It seems that caching packages in renv cause this error.

Solution: I did set the renv setting use.cash to F before i used renv::restore().

I would appreciate it if anyone does know more about that or have any good documentation regarding caching in renv.