This function updates the RStudio preferences saved in the rstudio-prefs.json file to include the secondary repositories passed my the user. If a new name for an existing repository is passed by the user, the name will be updated in the JSON file.

use_rstudio_secondary_repo(..., .write_json = TRUE, .backup = TRUE)



series of named secondary repositories, e.g. ropensci = ""


logical indicating whether to update and overwrite the existing JSON file of options. Default is TRUE. When FALSE, the function will return a list of all options, instead of writing them to file.


logical indicating whether to create a back-up of preferences file before it's updated. Default is TRUE


NULL, updates RStudio rstudio-prefs.json file


A note for users outside of the USA. If the country in .$cran_mirror$country has not been previously recorded in the JSON preferences file (typically, auto set by RStudio), the use_rstudio_secondary_repo() function will set "country" = "us".


Daniel D. Sjoberg


if (FALSE) { # interactive()
  ropensci = "",
  ddsjoberg = ""