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.
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.)
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.
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:
Close the project
Install package as normal (without renv)
Open the project using renv
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!
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.
utils::install.packages works, but install.packages fails with renv and the message
install.packages("data.table")
Error: package 'data.table' is not available
with utils::install.packages:
utils::install.packages("data.table")
Installing package into ‘/home/mshenton/analysis/haplotype_graphics/renv/library/R-4.1/x86_64-pc-linux-gnu’
(as ‘lib’ is unspecified) etc...
Also,
renv:::renv_download_file_method()
Error: object 'renv_download_file_method' not found
I have ran into a similar issue on Ubuntu 20.04.03. Feel free to read through my journey, or read what helped me at the bottom of this post.
Reproduction Steps
Enter an empty directory
Run R console
Run renv::init()
Restart R console
Try installing a package:
> renv::install("shiny")
Error: package 'shiny' is not available
In addition: Warning message:
could not retrieve available packages for url 'https://cloud.r-project.org/src/contrib'
Traceback (most recent calls last):
6: renv::install("shiny")
5: retrieve(names(remotes))
4: handler(package, renv_retrieve_impl(package))
3: renv_retrieve_impl(package)
2: stopf("package '%s' is not available", package)
1: stop(sprintf(fmt, ...), call. = call.)
Session Info
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=pl_PL.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=pl_PL.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=pl_PL.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=pl_PL.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_4.1.3 tools_4.1.3 renv_0.15.4
What I Tried
In addition to any proposed solution in this thread I have tried:
Changing R repository
Removing ~/.cache/R/renv
Removing ~/R , ~/.cache/R , and reinstalling R
Using different R consoles (RStudio, R, radian)
I have tried running renv within Docker and seeing if it is an issue with connectivity. It turned out that renv works in both:
rocker/r-base Docker image
ubuntu:focal Docker image with manually installed R
What Helped
With renv working in Docker images mimicking my system and not in the system itself I have scanned for any oddities that I do have installed.
It turned out that Nix the package manager and some packages I had installed through it were at fault. Purging Nix and its packages did resolve the issue for me. I have done that by removing /nix and ~/.nix-profile (note: this step depends on the way you have installed Nix). I suspect there was some masking going on that caused this issue.
Finally I realized that renv seems to change the repos.
Which seemed to affect utils::download.file.
Unfortunately my employer blocked all repos except rstudio.com, https is also blocked.
In my case following helped: options(repos="http://cran.rstudio.com/") Sys.setenv("RENV_CONFIG_REPOS_OVERRIDE" = "http://cran.rstudio.com")