Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a switch to not download from Github in offline mode when boostrapping #344

Closed
cderv opened this issue Feb 14, 2020 · 4 comments
Closed

Comments

@cderv
Copy link
Contributor

cderv commented Feb 14, 2020

I had an issue that freeze R on my RStudio servers because we are offline.

Currently, activate.R has a boostraping mechanism that will try to install from Github if last version available in CRAN is not the correct one.

message("* Downloading renv ", version, " ... ", appendLF = FALSE)
prefix <- "https://api.github.com"
url <- file.path(prefix, "repos/rstudio/renv/tarball", version)
destfile <- tempfile("renv-", fileext = ".tar.gz")
on.exit(unlink(destfile), add = TRUE)
utils::download.file(url, destfile = destfile, mode = "wb", quiet = TRUE)
message("Done!")

This would need to be deactivated in offline environment where we have only a package Manager or a CRAN mirror, at least with a switch using an option or an environment variable configure on the servers.

Also, how about bootstraping older version by installing from archive ?

Thanks.


The error in the servers

Failed to find installation of renv -- attempting to bootstrap...
* Downloading renv 0.8.2 ... Error in utils::download.file(url, destfile = destfile, mode = "wb", quiet = TRUE) : 
  impossible d'ouvrir l'URL 'https://api.github.com/repos/rstudio/renv/tarball/0.8.2'
De plus : Warning message:
In utils::download.file(url, destfile = destfile, mode = "wb", quiet = TRUE) :
  URL 'https://api.github.com/repos/rstudio/renv/tarball/0.8.2': status was 'Couldn't connect to server'
Warning message:
Failed to find an renv installation: the project will not be loaded.
Use `renv::activate()` to re-initialize the project. 
kevinushey added a commit that referenced this issue Feb 15, 2020
@kevinushey
Copy link
Collaborator

This has now been implemented -- renv will attempt to install from the CRAN archives before attempting to download from GitHub.

@j-kreis
Copy link

j-kreis commented Sep 16, 2021

Hello,

I face a similar issue when using renv in an offline session. The renv/activate.R script tries to access 'https://cloud.r-project.org' which results in a freeze of the RStudio session during activation/bootstrapping. I now manually update the hard-coded repository links in the renv/activate.R:88 script to our RSPM CRAN mirror checkpoints. Then it works perfectly. @kevinushey is there a cleaner way to circumvent this? I saw that you also look for the 'renv.repos.cran' option, should one set this value in the .Rprofile file?

Thank you!

@kevinushey
Copy link
Collaborator

You can set:

RENV_CONFIG_REPOS_OVERRIDE = <repoUrl>

See https://github.com/rstudio/renv/blob/master/R/bootstrap.R#L20-L49 for the associated logic.

@j-kreis
Copy link

j-kreis commented Sep 21, 2021

Hi @kevinushey,

I tried this solution and the bootstrapping works perfectly. However, we maintain multiple repositories and after restoring the project it is not possible to install packages from the other repositories, which are set in options('repos'). Is there any workaround available? (#716 might be related)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants