R/RStudio installation using domain allowlisting on Windows VMs

R/RStudio installation using domain allowlisting on Windows VMs

First version: 2022-08-22
Last version: 2023-12-15
Last change: Added an alternative for installing packages from Github (installation from manually downloaded repository).

This is a community effort. The article was created by the anDREa Support Team in their spare time. If you have found a more efficient way to approach this, please contact us and we will update the article.


For general domain allowlisting setup, please read more here.

Certain software might need manual proxy configurations to be set in the software settings, before the software is able to reach domains through a proxy. In this article we describe how to manually configure R/RStudio proxy settings in order to install packages using domain allowlisting.

Step 1: Allowlist domains (see also document about domain allowlists per application here)

Domain allowlisting is a self-service feature in the Workspace for Accountable and Privileged Members. To learn more, click here: Domain and IP Allowlisting [External Access]

Domains needed for packages from CRAN:
  1. posit.co (new domain for rstudio.com and rstudio.org)
  2. r-project.org
  3. rstudio.com (some network traffic is still rerouted to the old domain)
  4. rstudio.org (some network traffic is still rerouted to the old domain)
  5. OPTIONAL: Any domain of your choice for package repository (e.g. ac.at)
Domains needed for packages from Bioconductor:
  1. bioconductor.org
Domains needed for packages from Github:
  1. github.com
  2. git-scm.com
  3. githubusercontent.com
  4. githubassets.com

Step 2: Install R and RStudio as an Administrator

Only Accountables, Privileged and Advanced Members are able to install software in administrator mode on VMs (right click R or RStudio, run as admin).
IMPORTANT NOTE: Please note this has been tested with R-4.3.2 and might be different for other R versions.
  1. You can find the latest version of R and R Studio here: https://posit.co/download/rstudio-desktop/
    1. Some organizations have incorporated R and R Studio in their Software Store/Chocolatey. You can contact your local Support Team member to check this if you're not sure whether it is offered.
  2. If you need to compile packages, then you might also have to install R Tools that matches your R version: https://cran.r-project.org/bin/windows/Rtools/.
  3. If the domains are open, you can visit the above-mentioned links from within the Workspace and install the preferred versions of R and R Studio.

Step 3: Proxy configurations within R (only required once)

  1. The installation of R will create an R folder.
  2. Navigate to C:\Program Files\R\R-[your R version]\etc and open the Renviron.site file with Notepad++. 
    1. Replace [your R version] with the appropriate version.
If Renviron.site is missing, create an empty text file with Notepad++ and name it Renviron.site and place it in C:\Program Files\R\R-[your R version]\etc
  1. Add the proxy configuration settings as below and click Save All. It might complain about doing this as Administrator in Notepad++. Just click Yes and Save All again.

The file has been saved successfully when the Save icon turns blue from being red:  > . It might be that it asks you to open Notepad++ again as Administrator. Click Yes and go to File > Save All. The icon should now turn blue.
  1. Navigate to C:\Program Files\R\R-[your R version]\etc and open Rprofile.site file with Notepad++.
  1. Open this file with Notepad++ and add the same proxy configuration setting (line 23) at the bottom and click Save All. 

The file has been saved successfully when the Save icon turns blue from being red:  > 

Step 4: Disable setting in RStudio

  1. Restart RStudio as Administrator.
  2. In RStudio navigate to Tools > Global Options > Packages and disable Use secure download method for HTTP and click Apply.

Installing packages should work now, if the proper domains are whitelisted. 

Step 5: Install packages from CRAN

If you carefully followed the instructions above, you should be able to install packages in R. We strongly advise to install packages in ADMIN mode (right click R or RStudio, run as admin), as this ensures the installed packages are available for any user accessing the Windows VM.
  1. Find RStudio in the startmenu, right -click > More > click on Run as administrator;
  2. Install the required packages with:
Be aware that packages may encounter compatibility challenges with specific versions of R/RStudio

If you find that you're still experiencing problems with installing packages, you can also include the line in your code:
options(repos = c(CRAN_mirror = "http://cran.r-project.org"))
Still not working? Add a ticket and ask for assistance of your local the Support Team on support.mydre.org.

Step 6 (optional): Install packages from Bioconductor

  1. Make sure the proxy settings are correct. Make sure you have the exact same settings as in Step 3.
  2. Make sure bioconductor.org is allowlisted in your Workspace (as in Step 1).
  3. Open RStudio as Administrator.
  4. Install the BiocManager package:
  1. install.packages("BiocManager")
  1. You can now use BiocManager to install packages through Bioconductor:
  1. BiocManager::install("[packages]")
  1. Replace [packages] with the name of the package you want to install.

Step 7-A (optional): Install packages from Github

For an unidentified reason, Github is not reliably reachable through proxy, even with the correct proxy settings. You might see some errors such as error in utils or cannot open URL api.github.com. Getting this to work requires a bit more effort. 

The method below seems to work for the duration the VM is on Running. If you do find a more efficient way, please let us know and help out the community!
  1. Submit a ticket to your local Support Team to open up full internet for a short period. Provide at least:
    1. Workspace name in format dws-xxx-YYY.
    2. Approval of Accountable. Opening internet access comes with risks.
    3. Reason for opening up internet: downloading R packages from Github.
  2. Internet access will be opened up for a short period.
  3. Upon instruction, go the VM and search for Change Proxy Settings.

  1. Turn the option Use proxy server off. Notify your local Support Team.

  1. Internet access will be closed off and communicated.
  2. Turn the option Use a proxy server back on and click on Save.

  1. Now make sure the four Github domains are allowlisted in your Workspace (as in Step 1).
  2. Make sure all the proxy settings are correct like in Step 3.
  3. Open RStudio as Administrator.
  1. Install the package devtools: 
  1. install.packages("devtools")
  1. Load devtools: 
  1. library(devtools)
  1. Install package from a public Github repository:
  1. install_github("[repo]/[package]")
  1. Replace [repo] with the Github repository and [package] with the name of the package you want to install.
  2. If you want to install an R package from a private Github repository, you will need to append the authorisation token to the command above.

Step 7-B (optional): Install packages from Github from a local directory

This is an alternative to Step 7-A above. Since open access to the internet carries a lot of risk, this alternative might be preferable since it does not require internet access.
  1. If the Github domains have already been allowlisted as described above, navigate to the desired Github repository through a webbrowser in your Virtual Machine. If you did not and do not want to allowlist Github, you can also do this following step in another environment outside the Virtual Machine (e.g. the computer you are working from).
  2. Click on the green '<> Code' button and select Download ZIP to download the repository in a .zip archive.

  1. If you downloaded the repository from outside the VM, you can now upload the zip-archive to your workspace like you would usually upload your data.
  2. Next unzip the archive. The location where you unzip does not matter too much here.
  3. Open RStudio as Adminstrator and install the package:
  1. install.packages("C:/path to folder with the package", repos = NULL, type = "source")

    • Related Articles

    • R and RStudio using External Access rules

      This method of downloading R packages is outdated! This article will not be updated any longer. IP addresses are often subject to change. Therefore, the domain allowlisting feature has been introduced and it is self-service for Accountable and ...
    • Castor R-Package

      Prerequisites DRE: Owner access to workspace, to install R / RStudio / Rtools in a virtual machine External access to CRAN in the workspace where you want to export the data to (open up port rule) External access to Castor in the workspace where you ...
    • Windows-OSDS/1.0.0 Open Source Data Science

      Windows-OSDS/1.0.0 Open Source Data Science VM template This template has been discontinued, it is not up-to-date anymore. Please contact your local Support Team member for institute-specific VM templates. OS Windows Server 2019 Web browsers Chrome ...
    • Windows-RUMC-RPython 1.0.0

      Important! This image may only be deployed in Radboudumc workspaces. It is not permitted to deploy the template in a workspace of a different tenant. Thanks for understanding. The Windows-RUMC-RPython template is based on the Windows-RUMC-Base 2.0.0 ...
    • MATLAB / MathWorks installation and activation

      Introduction  This article links to knowledge base of MathWorks on how to install their products using network license and on offline machines.  See also: myDRE and Software Licenses If you have a working step-by-step procedure for yourself, please ...