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 “https://cran.r-project.org”, as shown in the below screenshot:

 

User-added image

2. You then need to install this User Plugin in order to expire the indexing retrieved from the remote repository on each request.

3. 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-remote”, so an install.packages() call can look like this –

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

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-remote

options(repos=r)

})

User-added image