@@ -26,20 +26,39 @@ if command -v uv &>/dev/null; then
2626fi
2727
2828# R configuration
29-
3029if command -v R & > /dev/null; then
3130 if [[ -n " $R_REPOSITORY " ]] || [[ -n " $PACKAGE_MANAGER_URL " ]]; then
3231 echo " configuration r (add local repository)"
3332
34- echo ' # https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux' >> ${R_HOME} /etc/Rprofile.site
35- echo ' options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))' >> ${R_HOME} /etc/Rprofile.site
33+ # /!\ Possible regression point for other users depending on this code.
34+ # The rocker image used as base injects a repository based on the CRAN environment variable, see for instance
35+ # https://github.com/rocker-org/rocker-versioned2/blob/677573589638617e04cad971ceafef84d5004f10/scripts/setup_R.sh#L34
36+ # This behavior might be unwanted when using an internal repository (eg: Nexus) instead of the public Posit
37+ # Package Manager instance. As such, when the PACKAGE_MANAGER_URL variable is set, we should overwrite
38+ # the Rprofile.site instead of appending to it. But as there might be unforeseen use cases where this
39+ # change could trigger problems, so I'm flagging this as such.
40+ if [[ -n " $PACKAGE_MANAGER_URL " ]]; then
41+ echo ' # Rocker default configuration removed by /opt/onyxia-set-repositories.sh' > ${R_HOME} /etc/Rprofile.site
42+
43+ # The unwanted behavior is setting options("repos"), but we might want to keep the user agent change from Rocker,
44+ # as this can potentially be used depending on how the local package manager is configured.
45+ echo ' # https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux' >> ${R_HOME} /etc/Rprofile.site
46+ echo ' options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])))' >> ${R_HOME} /etc/Rprofile.site
47+ fi
48+
3649 echo ' # Proxy repository for R' >> ${R_HOME} /etc/Rprofile.site
3750 echo ' local({' >> ${R_HOME} /etc/Rprofile.site
3851 echo ' r <- getOption("repos")' >> ${R_HOME} /etc/Rprofile.site
3952
4053 if [[ -n " $PACKAGE_MANAGER_URL " ]]; then
41- UBUNTU_CODENAME=$( cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)
42- echo " r[\" PackageManager\" ] <- \" ${PACKAGE_MANAGER_URL} /${UBUNTU_CODENAME} /latest\" " >> ${R_HOME} /etc/Rprofile.site
54+
55+ UBUNTU_CODENAME=$( cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)
56+ # Moving from "/__linux__/" style URLs to "/bin/linux" style URLS for PACKAGE_MANAGER_URL,
57+ # as this allows easier management for local package managers (at least Nexus, where it allows
58+ # using a single repository as opposed to one per major.minor version of R)
59+ # See also : https://docs.posit.co/rspm/admin/serving-binaries.html#using-linux-binary-packages
60+ # echo " r[\"PackageManager\"] <- \"${PACKAGE_MANAGER_URL}/${UBUNTU_CODENAME}/latest\"" >> ${R_HOME}/etc/Rprofile.site
61+ echo " r[\" PackageManager\" ] <- sprintf(\" ${PACKAGE_MANAGER_URL} /latest/bin/linux/${UBUNTU_CODENAME} -%s/%s\" , R.version[\" arch\" ], substr(getRversion(), 1, 3))" >> ${R_HOME} /etc/Rprofile.site
4362 fi
4463
4564 if [[ -n " $R_REPOSITORY " ]]; then
0 commit comments