Overview
Artifactory natively supports CRAN repositories for the R language, giving you full control of your deployment and resolving process of CRAN packages. Starting from Artifactory version 7.41.1, you can configure local CRAN repositories to adhere to the official CRAN specification requirements by enabling the artifactory.cran.archiveMover.enabled
to true (Default value is false) system property within the artifactory.system.properties file located at $JFROG_HOME/artifactory/var/etc/artifactory.
A restart of Artifactory is needed for changes to take effect.
Afterward, we must execute the Move Archive API in order to move the existing archives from the wrong location to the correct location.
curl -u "admin:password" -X GET "https://company.jfrog.io/artifactory/api/cran/repo-local/move-archives"
Resolving CRAN Packages via the R Command Line
Installing Packages:
Typically, to install a package from a CRAN repository, the following R command is used:
install.packages("package_name") This command defaults to installing the latest version of the specified package.
Resolving Specific Archive Versions
To resolve a particular version of a package stored in your local CRAN repository under the Archives path, you may use "renv" which serves as a dependency management toolkit for R. This tool is compatible with the Archive layout of Artifactory's local CRAN repositories.
More information regarding “renv” can be found here.
Configuring Your R Client:
First, ensure your R client is configured to point to Artifactory by adding the following lines to your RProfile.site file:
local({
r <- list("cran-local" = "http://admin:<PASSWORD>@<JFROG_URL>/artifactory/cran-local/")
options(repos = r)
}) Replace <PASSWORD> and <JFROG_URL> with your actual Artifactory credentials and URL. In this example, the “cran-local” stands for the local CRAN repository name in Artifactory.
Installing a Specific Version:
To install a specific version of a package, execute the following command in RStudio or your R terminal:
renv::install("package_name@version") For instance, to install version 1.3.3 of the "activity" package, you may use:
renv::install("activity@1.3.3")
Installing "renv":
If "renv" is not installed on your system, you can install it using:
install.packages("renv")
Note: It's important to note that the process described above is only applicable when the artifactory.cran.archiveMover.enabled system property is set to true in the artifactory.system.properties file.