renv fails on install.packages() and restore()

In both new (dummy) packages and mature packages with renv already initialized, renv fails on install.packages() and restore() .

Failure on install.packages(), with, e.g., dplyr:

> install.packages("dplyr")
Retrieving 'https://cloud.r-project.org/bin/macosx/contrib/4.2/dplyr_1.1.0.tgz' ...
	OK [downloaded 1.5 Mb in 0.4 secs]
Retrieving 'https://cloud.r-project.org/bin/macosx/contrib/4.2/cli_3.6.0.tgz' ...
	OK [file is up to date]

[...]

Retrieving 'https://cloud.r-project.org/bin/macosx/contrib/4.2/withr_2.5.0.tgz' ...
	OK [file is up to date]
Installing cli [3.6.0] ...
	FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning message:
In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

Failure on renv::restore():

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

# CRAN ===============================
- KernSmooth            [2.23-20 -> 2.23-18]
- MASS                  [7.3-58.2 -> 7.3-53.1]

[...]

- zip                   [* -> 2.2.2]

# GitHub =============================
- staged.dependencies   [* -> remoteproject/staged.dependencies@HEAD]

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.microsoft.com/snapshot/2021-03-31/src/contrib/boot_1.3-27.tar.gz' ...
	OK [file is up to date]
Retrieving 'https://cran.microsoft.com/snapshot/2021-03-31/src/contrib/class_7.3-18.tar.gz' ...
	OK [file is up to date]

[...]

Retrieving 'https://cran.microsoft.com/snapshot/2021-03-31/src/contrib/visNetwork_2.0.9.tar.gz' ...
	OK [file is up to date]
Installing boot [1.3-27] ...
	FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning messages:
1: could not retrieve available packages for url 'https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2' 
2: In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

Session info:

> sessionInfo()

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] MASS_7.3-58.2  compiler_4.2.1 tools_4.2.1    renv_0.16.0 

Judging from answers here and in other forums, the following might be useful information:

  1. Output from getOption("repos"):
> getOption("repos")
                                            CRAN                                             MRAN 
                   "https://cloud.r-project.org" "https://cran.microsoft.com/snapshot/2021-03-31" 
  1. Output from installing directly from utils package:
> utils::install.packages("dplyr")

Installing package into ‘/Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘fansi’, ‘utf8’, ‘pkgconfig’, ‘withr’, ‘cli’, ‘generics’, ‘glue’, ‘lifecycle’, ‘magrittr’, ‘pillar’, ‘R6’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’

Warning: unable to access index for repository https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2:
  cannot open URL 'https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2/PACKAGES'

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/fansi_1.0.4.tgz'
Content type 'application/x-gzip' length 364195 bytes (355 KB)
==================================================
downloaded 355 KB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/utf8_1.2.3.tgz'
Content type 'application/x-gzip' length 196823 bytes (192 KB)
==================================================
downloaded 192 KB

[...]

The downloaded binary packages are in
	/var/folders/41/y38m8sw12871hpn_5nl9y88m0000gn/T//RtmpIwcHeu/downloaded_packages
  1. Output from renv::diagnostics():
> renv::diagnostics()
Diagnostics Report [renv 0.16.0]
================================

# Session Info =======================
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] MASS_7.3-58.2  compiler_4.2.1 tools_4.2.1    renv_0.16.0   

# Project ============================
Project path: "~/Desktop/Git_Repos/project"

# Status =============================
The following package(s) do not appear to be used in this project:
               _
  BH             [1.75.0-0]
  KernSmooth     [2.23-18]
  [...]
  zip            [2.2.2]

Use `renv::snapshot()` to remove them from the lockfile.

The following package(s) are recorded in the lockfile, but not installed:
                      _
  DT                    [0.17]
  covr                  [3.5.1]
  [...]
  staged.dependencies   [remoteproject/staged.dependencies@HEAD]
  usethis               [2.1.6]

Use `renv::restore()` to install these packages.

The following package(s) are out of sync:

    Package   Lockfile Version   Library Version
         R6              2.5.0             2.5.1
        cli              3.4.1             3.6.0
      [...]
      vctrs              0.5.0             0.5.2

Use `renv::snapshot()` to save the state of your library to the lockfile.
Use `renv::restore()` to restore your library from the lockfile.

The following package(s) are used in the project, but are not installed:

	project.test
	projectdev

Consider installing these packages, and then using `renv::snapshot()`
to record these packages in the lockfile.


# Packages ===========================
                     Library Source Lockfile Source Path Dependency
BH                      <NA>   <NA> 1.75.0-0   CRAN <NA>       <NA>
DT                      <NA>   <NA>     0.17   CRAN <NA>     direct
[...]
zip                     <NA>   <NA>    2.2.2   CRAN <NA>       <NA>

[1]: /Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0
[2]: /Users/dlei/Desktop/Git_Repos/project/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/84ba8b13               

# ABI ================================
* No ABI conflicts were detected in the set of installed packages.

# User Profile =======================
[no user profile detected]

# Settings ===========================
List of 10
 $ bioconductor.version     : chr(0) 
 $ external.libraries       : chr(0) 
 $ ignored.packages         : chr(0) 
 $ package.dependency.fields: chr [1:3] "Imports" "Depends" "LinkingTo"
 $ r.version                : chr(0) 
 $ snapshot.type            : chr "implicit"
 $ use.cache                : logi TRUE
 $ vcs.ignore.cellar        : logi TRUE
 $ vcs.ignore.library       : logi TRUE
 $ vcs.ignore.local         : logi TRUE

# Options ============================
List of 9
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : chr "libcurl"
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: chr "interactive"
 $ pkgType                             : chr "both"
 $ repos                               : Named chr [1:2] "https://cloud.r-project.org" "https://cran.microsoft.com/snapshot/2021-03-31"
  ..- attr(*, "names")= chr [1:2] "CRAN" "MRAN"
 $ renv.consent                        : logi TRUE
 $ renv.project.path                   : chr "/Users/dlei/Desktop/Git_Repos/project"
 $ renv.verbose                        : logi TRUE

# Environment Variables ==============
HOME                        = /Users/dlei
LANG                        = en_CA.UTF-8
MAKE                        = make
R_LIBS                      = <NA>
R_LIBS_SITE                 = /Library/Frameworks/R.framework/Resources/site-library
R_LIBS_USER                 = /Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0:/Users/dlei/Desktop/Git_Repos/project/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/84ba8b13
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = /Library/Frameworks/R.framework/Resources/site-library
RENV_DEFAULT_R_LIBS_USER    = /Users/dlei/Library/R/x86_64/4.2/library
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = /Users/dlei/Desktop/Git_Repos/project

# PATH ===============================
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin
- 
- /Applications/RStudio.app/Contents/MacOS/postback

# Cache ==============================
There are a total of 0 package(s) installed in the renv cache.
Cache path: "~/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.2/x86_64-apple-darwin17.0"

  1. Output of getOption("download.file.method"):
> getOption("download.file.method")
[1] "libcurl"
  1. Output of renv:::renv_download_method():
> renv:::renv_download_method()
[1] "curl"
  1. As per recommendation in the RStudio community forum, I've tried setting renv's download method from curl to libcurl, but get a similar error:
> install.packages("dplyr")
Retrieving 'https://cloud.r-project.org/bin/macosx/contrib/4.2/dplyr_1.1.0.tgz' ...
	OK [downloaded 1.5 Mb in 0.3 secs]
Installing dplyr [1.1.0] ...
	FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning messages:
1: could not retrieve available packages for url 'https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2' 
2: In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

The issue, is not about download method; its more about the URL itself.
you are succeeding where the urls are of the form : https://cloud.r-project.org/bin/macosx/contrib/4.2
(these dont have dates in them)
the renv ones you report failing are using cran snapshots.
and there is simply no corresponding URL for the ones they try to read. Probably related to the release date of R4.2
try to browse the link to see for yourself :
https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2
wherease there would be an entry for 4.1 at that date
https://cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.1

In your shoes I think I might try

restore(repos="https://cloud.r-project.org")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.