InseeFrLab / images-datascience

Collection of Docker images to build the data science catalog of the Onyxia project
MIT License
24 stars 23 forks source link

RStudio : correction on RProfile.site file if a proxy repository is configured #74

Closed phlg closed 1 year ago

phlg commented 1 year ago

After further testing of the RStudio image behind a proxy repository, I found that the configuration I suggested in https://github.com/InseeFrLab/images-datascience/pull/64 was not ideal. In its current state, RStudio first tries to download packages from the builtin repository (https://packagemanager.rstudio.com/cran at the time of the writing), and only tries the proxy repository after this one times out.

To change this behavior, this PR suggests rewriting the whole /usr/local/lib/R/etc/R/Rprofile.site file (instead of appending to it). The line that appears to have been added in the file changes was present in the original file, which was the following for reference :

options(repos = c(CRAN = 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'), download.file.method = 'libcurl')
# https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux
options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))
# Proxy repository for R
local({
r <- getOption("repos")
r["LocalRepository"] <- "*** REDACTED INTERNAL PROXY REPOSITORY ***"
options(repos = r)
})