How to proxy a CRAN repo with Artifactory

Artifactory can act as a CRAN proxy against other third-party CRAN repositories, to achieve effective caching of CRAN packages. This can be done with the use of Remote Repositories. A basic setup would be as follows:


Create a new remote repository in Artifactory and configure the URL of the remote repository to a select CRAN mirror / endpoint, such as “http://cran.rstudio.com/”, as shown in the screenshot below:

 

 


2. You can then configure the CRAN client to use your newly created remote repository in Artifactory when installing packages. The name of my remote repository is “cran”, so an install.packages() call can look like this:

install.packages(‘RMySQL’, repos=’http://localhost:8081/artifactory/cran‘)


Or, you could set Artifactory as the default CRAN repository by creating a ~/.Rprofile file and adding this to the file –


local({r <- getOption(“repos”)

r[“CRAN”] <- “http://localhost:8081/artifactory/cran

options(repos=r)

})


3. You can find a User plugin on our GitHub repository that can help expire PACKAGES.gz metadata files for mirroring a remote repository.