CRAN Repository

Cloudsmith provides public & private repositories for R packages

835

R is a free software environment for statistical computing and graphics. CRAN or Comprehensive R Archive Network is the repository for R packages.

For more information on R, please see:

  • R: The official website for R
  • CRAN: The official list of mirrors public repositories
  • CRAN Package Repository: The official package repository
Contextual Documentation

The examples in this document are generic. Cloudsmith provides contextual setup instructions within each repository, complete with copy n' paste snippets (with your namespace/repo/rsa-key pre-configured).

In the following examples:

IdentifierDescription
OWNERYour Cloudsmith account name or organisation name (namespace)
REPOSITORYYour Cloudsmith Repository name (also called "slug")
TOKENYour Cloudsmith Entitlement Token (see Entitlements for more details)
USERNAMEYour Cloudsmith username
PASSWORDYour Cloudsmith password
API-KEYYour Cloudsmith API Key
PACKAGE_NAMEThe name of your package
PACKAGE_VERSIONThe version number of your package

Upload a Package

To upload, you will need to generate a package first. Hadley Wickham's R Packages book provides the best overview of what is required to do so. We highly recommend following the best practices outlined in the book (it's available free online).

Upload via the Cloudsmith CLI

For full details of how to install and setup the Cloudsmith CLI, see Command Line Interface.

The command to upload an R/CRAN package via the Cloudsmith CLI is:

cloudsmith push cran OWNER/REPOSITORY PACKAGE_NAME_PACKAGE_VERSION.tar.gz

Example:

cloudsmith push cran org/repo your-package_0.1.0.tar.gz

Upload via Cloudsmith Website

Please see Upload a Package for details of how to upload via the Website UI.


Download / Install a Package

To install a package, you use the install.packages method directly in your R session:

Public Repositories

install.packages(
  "PACKAGE_NAME",
  repos = c(cloudsmith = "https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cran/")
)

Private Repositories

📘

Private Cloudsmith repositories require authentication. You can choose between two types of authentication, Entitlement Token Authentication or HTTP Basic Authentication.

The setup method will differ depending on what authentication type you choose to use.

🚧

Entitlement Tokens, User Credentials and API-Keys should be treated as secrets, and you should ensure that you do not commit them in configurations files along with source code or expose them in any logs

install.packages(
  "PACKAGE_NAME",
  repos = c(cloudsmith = "https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/cran/")
)
install.packages(
  "PACKAGE_NAME",
  repos = c(cloudsmith = "https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/cran/")
)
install.packages(
  "PACKAGE-NAME",
  repos = c(cloudsmith = "https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/cran/")
)
install.packages(
  "PACKAGE-NAME",
  repos = c(cloudsmith = "https://token:[email protected]/basic/OWNER/REPOSITORY/cran/")
)

For most use cases, users will probably want to persist their repository settings and not specify them every time. To set the repository and avoid having to specify this during every package installation, create the R startup command file .Rprofile in your home directory and add the following R code to it:

Public Repositories

print("Configuring CRAN repositories")
r = getOption("repos")
r["cloudsmith"] = "https://dl.cloudsmith.io/public/OWNER/REPOSITORY/cran/"
r["CRAN"] = "https://cloud.r-project.org"
options(repos = r)
rm(r)

Private Repositories

print("Configuring CRAN repositories")
r = getOption("repos")
r["cloudsmith"] = "https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/cran/"
r["CRAN"] = "https://cloud.r-project.org"
options(repos = r)
rm(r)
print("Configuring CRAN repositories")
r = getOption("repos")
r["cloudsmith"] = "https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/cran/"
r["CRAN"] = "https://cloud.r-project.org"
options(repos = r)
rm(r)
print("Configuring CRAN repositories")
r = getOption("repos")
r["cloudsmith"] = "https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/cran/"
r["CRAN"] = "https://cloud.r-project.org"
options(repos = r)
rm(r)
print("Configuring CRAN repositories")
r = getOption("repos")
r["cloudsmith"] = "https://token:[email protected]/basic/OWNER/REPOSITORY/cran/"
r["CRAN"] = "https://cloud.r-project.org"
options(repos = r)
rm(r)

Upstream Proxying / Caching

Not Supported

Troubleshooting

Please see the Troubleshooting page for further help and information.


Cloudsmith is the new standard in Package / Artifact Management and Software Distribution

With support for all major package formats, you can trust us to manage your software supply chain.


Start My Free Trial Now
Cookie Declaration (Manage Cookies)