|
| 1 | +--- |
| 2 | +title: "Depending on a development version" |
| 3 | +vignette: > |
| 4 | + %\VignetteIndexEntry{Depending on a development version} |
| 5 | + %\VignetteEngine{quarto::html} |
| 6 | + %\VignetteEncoding{UTF-8} |
| 7 | +--- |
| 8 | + |
| 9 | +Sometimes you need your package to depend on a development version of another package that isn't yet available on [CRAN](https://cran.r-project.org) or [Bioconductor](https://bioconductor.org/). |
| 10 | +The `Remotes` field in `DESCRIPTION` lets you specify where to install such a dependency from. |
| 11 | +**`Remotes` is not a standard `DESCRIPTION` field**. |
| 12 | +It is not acceptable when releasing a package on CRAN. |
| 13 | +The `Remotes` field is understood by devtools, [pak](https://pak.r-lib.org/), and related tools, and is meant to be a temporary measure during development. |
| 14 | + |
| 15 | +This vignette covers the mechanics of the `Remotes` field. |
| 16 | +For more context, see the [Nonstandard dependencies](https://r-pkgs.org/dependencies-in-practice.html#nonstandard-dependencies) section of the R Packages book. |
| 17 | + |
| 18 | +## The `Remotes` field |
| 19 | + |
| 20 | +You can mark any dependency listed in `Depends`, `Imports`, `Suggests`, or `Enhances` as being installed from a non-standard source by adding a package reference to `Remotes` in your `DESCRIPTION` file. |
| 21 | + |
| 22 | +The general form is: |
| 23 | + |
| 24 | +``` |
| 25 | +Remotes: [type::]<source>, [type2::]<source2> |
| 26 | +``` |
| 27 | + |
| 28 | +Multiple remote dependencies are separated by commas, just like regular dependencies elsewhere in `DESCRIPTION`. |
| 29 | + |
| 30 | +It is important to remember that you **must always declare the dependency in the usual way**, i.e. in `Depends`, `Imports`, `Suggests`, or `Enhances`. |
| 31 | +The `Remotes` field only provides instructions about *where* to install the dependency from. |
| 32 | +For example, note how rlang appears in both `Imports` and `Remotes`: |
| 33 | + |
| 34 | +``` |
| 35 | +Package: mypackage |
| 36 | +Title: What the Package Does (One Line, Title Case) |
| 37 | +Version: 0.0.0.9000 |
| 38 | +Imports: |
| 39 | + rlang (>= 1.1.0.9000) |
| 40 | +Remotes: |
| 41 | + r-lib/rlang |
| 42 | +``` |
| 43 | + |
| 44 | +You can use `usethis::use_dev_package()` to add or update a development dependency. |
| 45 | +It takes care of modifying both the `Imports` (or `Suggests`) and `Remotes` fields. |
| 46 | + |
| 47 | +## GitHub |
| 48 | + |
| 49 | +GitHub is the most commonly used source for development packages, and the default when no type prefix is specified: |
| 50 | + |
| 51 | +```yaml |
| 52 | +Remotes: r-lib/rlang |
| 53 | +``` |
| 54 | +
|
| 55 | +You can request a specific branch, tag, commit (SHA), or pull request: |
| 56 | +
|
| 57 | +```yaml |
| 58 | +Remotes: r-lib/rlang@some-branch, |
| 59 | + r-lib/rlang@v1.0.0, |
| 60 | + r-lib/rlang@84be6207, |
| 61 | + r-lib/rlang#142 |
| 62 | +``` |
| 63 | +
|
| 64 | +A `github::` prefix is accepted but not required: |
| 65 | + |
| 66 | +```yaml |
| 67 | +Remotes: github::r-lib/rlang |
| 68 | +``` |
| 69 | + |
| 70 | +## Other sources |
| 71 | + |
| 72 | +There are many other supported source types: |
| 73 | + |
| 74 | +```yaml |
| 75 | +# GitLab |
| 76 | +Remotes: gitlab::user/repo |
| 77 | +
|
| 78 | +# Git (any host) |
| 79 | +Remotes: git::https://github.com/r-lib/rlang.git |
| 80 | +
|
| 81 | +# Bioconductor |
| 82 | +Remotes: bioc::SummarizedExperiment |
| 83 | +
|
| 84 | +# URL (package archive) |
| 85 | +Remotes: url::https://example.com/package-0.1.0.tar.gz |
| 86 | +
|
| 87 | +# Local |
| 88 | +Remotes: local::/path/to/package |
| 89 | +``` |
| 90 | + |
| 91 | +See the [pak documentation on package sources](https://pak.r-lib.org/reference/pak_package_sources.html) for a complete list. |
| 92 | + |
| 93 | +## CRAN submission |
| 94 | + |
| 95 | +When you submit your package to CRAN, all of its dependencies must also be available on CRAN or Bioconductor. |
| 96 | +You need to remove the `Remotes` field from your `DESCRIPTION` before submission. |
| 97 | +This means having a `Remotes` field is a temporary development state: once the dependency you need is released to CRAN or Bioconductor, you should update your minimum version requirement and drop the `Remotes` entry. |
0 commit comments