CRAN Repository
Cloudsmith provides public & private repositories for R packages

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
In the following examples:
Identifier | Description |
---|---|
OWNER | Your Cloudsmith account name or organisation name (namespace) |
REPOSITORY | Your Cloudsmith Repository name (also called "slug") |
TOKEN | Your Cloudsmith Entitlement Token (see Entitlements for more details) |
USERNAME | Your Cloudsmith username |
PASSWORD | Your Cloudsmith password |
API-KEY | Your Cloudsmith API Key |
PACKAGE_NAME | The name of your package |
PACKAGE_VERSION | The 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.
Updated over 1 year ago