Open wibom opened 2 months ago
I wonder if this is possibly an RStudio issue -- do you see the same behavior if you use renv
outside of RStudio; e.g. in RGui on Windows?
Thanks for your input!!!
It seems you are right about Rstudio being the culprit for ignoring the global "repos"
option. I'll see if I can find an appropriate repo to post that part of the issue in...
However, also when running directly in the Rgui for windows, the time it takes to grab a package is controlled by the RENV_CONFIG_CONNECT_TIMEOUT
-setting. That seems a bit strange.
Here are some quick tests from Rgui on Windows:
# Global options
dir.create("test-renv-1")
setwd("test-renv-1")
renv::status()
#> This project does not appear to be using renv.
#> Use `renv::init()` to initialize the project.
getOption("repos")
#> CRAN
#> "https://my.mirror.com/"
# Create renv-managed project
renv::init(bare = TRUE)
#> - renv activated -- please restart the R session.
### RESTART
setwd("test-renv-1")
source("renv/activate.R")
renv::snapshot()
renv::status()
#> No issues found -- the project is in a consistent state.
getOption("repos")
#> CRAN
#> "https://my.mirror.com/"
So far so good. The global options are respected by renv
.
However, the actual time it takes to get a package can still be controlled by the RENV_CONFIG_CONNECT_TIMEOUT
-setting.
renv::install("tictoc")
Sys.getenv("RENV_CONFIG_CONNECT_TIMEOUT")
#> [1] "15"
tictoc::tic()
renv::install("digest", prompt = FALSE)
tictoc::toc()
#> 15.74 sec elapsed
Sys.setenv(RENV_CONFIG_CONNECT_TIMEOUT = 25)
tictoc::tic()
renv::install("digest", prompt = FALSE)
#> The following package(s) will be installed:
#> - digest [0.6.37]
#> These packages will be installed into "~/test-renv-1/renv/library/windows/R-4.4/x86_64-w64-mingw32".
#> # Installing packages --------------------------------------------------------
#> - Installing digest ... OK [copied from cache in 0.37s]
#> Successfully installed 1 package in 0.43 seconds.
tictoc::toc()
#> 25.75 sec elapsed
Could this a bug somewhere? Or have I messed up the configurations somewhere 🤔?
I found the reason that the RENV_CONFIG_CONNECT_TIMEOUT
-setting controls the time it takes renv::install()
to install a package.
Tracing the call stack of renv::install
, I found this call some way down the stack: renv:::renv_p3m_database_refresh(explicit = FALSE)
. On our locked down server, the call results in # Error: error downloading 'https://rstudio-buildtools.s3.amazonaws.com/renv/package-manager/packages.rds' [error code 28]
.
The ERROR is handled within renv:::renv_available_packages_latest()
and hidden from the user.
Now that I know what is going on, it's easy to fix by setting renv.config.ppm.enabled
and/or renv.config.ppm.default
to FALSE
(both defaults to TRUE
):
renv::init()
to override any customization of the global repos
-option and replace it by cloud.r-project.org
.renv.config.ppm.enabled
.
When in an renv-managed Rstudio project the user repository configuration is ignored.
The server I am working on does not have open internet access. I need to use a specific repos address, we'll call it
"https://my.mirror.com/"
.Global options
I have set the CRAN-mirror to use in the
.Rprofile
.Project options
When moving in to a project, not yet managed by
renv
, the global options are still respected:Initiating
renv
overrides the global optionsWhen initiating
renv
the custom global option is replaced bycloud.r-project.org
:The
repos
argument torenv::init()
also is not respected:Passing in the CRAN mirror using the
repos
argument when initiatingrenv
in the project has no effect:Setting the
repos
option after initiatingrenv
also is not respected:Let's try setting the
repos
-option AFTER initiatingrenv
:Now it would appear all configurations are in place. However, I still don't think they are respected by
renv
. Consider the following:Let's see the time it takes to install a package using
renv::install()
:I don't know what happens during the time it takes
renv::install()
to install the package, but the fact that we can control how long it takes by changing theRENV_CONFIG_CONNECT_TIMEOUT
-setting indicates thatrenv
is attempting to connect to somewhere other than the repository specified bygetOption("repos")
/Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE")
.renv::diagnostics()