Can't install packages with renv

Hi everyone,

I'm trying to get started using renv, but I can't seem to install any packages with renv activated.

I simply get 'Error: package "..." is not available' for any package I try to install, with no further warnings or explanations.

This seems to happen across all projects. Below is a transcript from a completely new/empty project.


R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> renv::init()
* Initializing project ...
* Discovering package dependencies ... Done!
* Copying packages into the cache ... Done!
The following package(s) will be updated in the lockfile:

# CRAN ===============================
- renv   [* -> 0.12.5]

* Lockfile written to '~/Projects/TestProject/renv.lock'.

Restarting R session...

* Project '~/Projects/TestProject' loaded. [renv 0.12.5]
> install.packages("tidyverse")
Error: package 'tidyverse' is not available
> renv::deactivate()

Restarting R session...

> install.packages("tidyverse")
Installing package into ‘/home/user/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/tidyverse_1.3.0.tar.gz'
Content type 'application/x-gzip' length 712837 bytes (696 KB)
==================================================
downloaded 696 KB

* installing *source* package ‘tidyverse’ ...
** package ‘tidyverse’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Warning: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Warning: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
** testing if installed package can be loaded from final location
Warning: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
** testing if installed package keeps a record of temporary installation path
* DONE (tidyverse)

The downloaded source packages are in
	‘/tmp/RtmpBmDMyr/downloaded_packages’
> renv::activate()
* Project '~/Projects/TestProject' loaded. [renv 0.12.5]
> install.packages("tidyverse")
Error: package 'tidyverse' is not available

I don't have any idea where to even start looking for the source of this problem. Any help would be greatly appreciated.

Sorry to hear you're having trouble! Can you check a couple things?

  • What is the output of getOption("repos") in your project, when renv is active?

  • Does installation succeed after activating renv, if you use utils::install.packages() directly?

The output of renv::diagnostics() may also be helpful.

Thanks for the response. I've responded below

> getOption("repos")
                         CRAN 
"https://cloud.r-project.org" 

yes it completes successfully.

> utils::install.packages("magrittr")
Installing package into ‘/home/garrett/Projects/TestProject/renv/library/R-3.6/x86_64-pc-linux-gnu’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/magrittr_2.0.1.tar.gz'
Content type 'application/x-gzip' length 265580 bytes (259 KB)
==================================================
downloaded 259 KB

* installing *source* package ‘magrittr’ ...
** package ‘magrittr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-t3diwe/r-base-3.6.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c pipe.c -o pipe.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-t3diwe/r-base-3.6.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c utils.c -o utils.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o magrittr.so pipe.o utils.o -L/usr/lib/R/lib -lR
installing to /home/garrett/Projects/TestProject/renv/library/R-3.6/x86_64-pc-linux-gnu/00LOCK-magrittr/00new/magrittr/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (magrittr)

The downloaded source packages are in
	‘/tmp/RtmpJliAwO/downloaded_packages’
> install.packages("magrittr")
Error: package 'magrittr' is not available
> renv::diagnostics()
Diagnostics Report -- renv [0.12.5]
===================================

# Session Info =======================
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.1

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.6.2 tools_3.6.2    renv_0.12.5   

# Project ============================
Project path: "~/Projects/TestProject"

# Status =============================
* The project is already synchronized with the lockfile.

# Packages ===========================
         Library Source Lockfile Source Path Dependency
magrittr   2.0.1   CRAN     <NA>   <NA>  [1]       <NA>
renv      0.12.5   CRAN   0.12.5   CRAN  [1]     direct
utils       <NA>   <NA>     <NA>   <NA>  [2]   indirect

[1]: /home/user/Projects/TestProject/renv/library/R-3.6/x86_64-pc-linux-gnu
[2]: /tmp/RtmpJliAwO/renv-system-library                                      

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

# Settings ===========================
List of 7
 $ 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.library       : logi TRUE

# Options ============================
List of 2
 $ renv.consent: logi TRUE
 $ renv.verbose: logi TRUE

# Environment Variables ==============
HOME                        = /home/user
LANG                        = en_US.UTF-8
R_LIBS                      = <NA>
R_LIBS_SITE                 = /usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER                 = /home/user/Projects/TestProject/renv/library/R-3.6/x86_64-pc-linux-gnu:/tmp/RtmpOjgGgV/renv-system-library
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = /usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
RENV_DEFAULT_R_LIBS_USER    = ~/R/x86_64-pc-linux-gnu-library/3.6
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = /home/user/Projects/TestProject

# PATH ===============================
- /home/user/bin
- /home/user/.guix-profile/bin
- /home/user/.config/guix/current/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin

# Cache ==============================
There are a total of 300 package(s) installed in the renv cache.
Cache path: "~/.local/share/renv/cache/v5/R-3.6/x86_64-pc-linux-gnu"

Thanks! Can you also share the output of:

getOption("download.file.method")
renv:::renv_download_file_method()

I wonder if renv is selecting a different download method that for some reason does not work on your machine. If that's the case, then setting:

RENV_DOWNLOAD_FILE_METHOD = <method>

where <method> is the same as what's currently set for the download.file.method option should help. (That can be set in your project's .Renviron file.)

I would expect installations involving renv to use renv::install(), but it doesnt seem that appears anywhere in this thread ... ?

nevermind, i see its a renv:shims !

Looks like that was it!

getOption("download.file.method") was returning "libcurl"
and renv:::renv_download_file_method() returns "curl"

It looks like I had accidentally to install curl as guix user profile package, so which curl was pointing at "~/.guix_profile/bin/curl" rather than the system curl.

Removing that so R finds the system curl fixed the problem. Though I still don't know what the problem with the guix curl binary was.

Setting RENV_DOWNLOAD_FILE_METHOD="libcurl" worked too, but I didn't actually want the guix package installed, anyway.

Thanks so much for the help!

I also have the same problem when using my Windows machine (I work on the same repo with a Linux machine and a Windows one: linux works great, wereas Windows does not).

I tried to reproduce it by running:

Sys.setenv(RENV_DOWNLOAD_METHOD = "libcurl")

But doesn't work. As a workaround I did the following:

  1. Close the project
  2. Install package as normal (without renv)
  3. Open the project using renv
  4. Restore snapshot

If the packages have previously been installed, they will be symlinked and they would work.

Unfortunately, this is extremely cumbersome, as many packages have dependencies and I have to manually install them all, and that's precisely one of the things I want to avoid and one of the reasons for using renv!

That's what I get:

> getOption("download.file.method")
[1] "wininet"
> renv:::renv_download_file_method()
[1] "curl"
>

And this is the error I get after running: Sys.setenv(RENV_DOWNLOAD_METHOD = "curl") (or wininet or libcurl)

Error: failed to retrieve package 'xfun'
In addition: Warning messages:
1: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
2: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
3: download failed [error code 35]
4: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.
5: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.