Skip to content

Commit 19bf6b1

Browse files
committed
Support rig pkg install --dev
1 parent d389fe1 commit 19bf6b1

4 files changed

Lines changed: 282 additions & 3 deletions

File tree

src/args.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,24 @@ pub fn rig_app() -> Command {
16601660
.num_args(0)
16611661
.required(false),
16621662
)
1663+
.arg(
1664+
Arg::new("dev")
1665+
.help("Include dev (development) dependencies")
1666+
.long("dev")
1667+
.num_args(0)
1668+
.required(false),
1669+
)
1670+
.arg(
1671+
Arg::new("ignore-unavailable")
1672+
.help(
1673+
"Skip dev dependencies that are not available in the\n\
1674+
repositories, instead of failing",
1675+
)
1676+
.long("ignore-unavailable")
1677+
.num_args(0)
1678+
.requires("dev")
1679+
.required(false),
1680+
)
16631681
.arg(
16641682
Arg::new("platform")
16651683
.help(

src/help-generated.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const HELP_PKG_DEPS: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m
4141
const ABOUT_PKG_INFO: &str = "Information about a package in the repositories";
4242
const HELP_PKG_INFO: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Show information about a package on CRAN, from its \u{1b}[32mDESCRIPTION\u{1b}[39m file.\n\n By default the latest available version is shown; use \u{1b}[32m--version\u{1b}[39m to\n select a specific one, including versions that CRAN has archived. Use\n \u{1b}[32m--json\u{1b}[39m to print all \u{1b}[32mDESCRIPTION\u{1b}[39m fields.\n\n If CRAN has archived the package, i.e. removed it from the current\n repository, rig shows the date it was archived, next to the publication\n date of the version. \u{1b}[32m--json\u{1b}[39m reports it as an extra \u{1b}[32mArchived\u{1b}[39m field.\n\n\u{1b}[1m\u{1b}[34mREADME of a package:\u{1b}[39m\u{1b}[22m\n \u{1b}[32m--readme\u{1b}[39m prints the README of the package, instead of its metadata,\n exactly as the repository stores it, i.e. not rendered and not paged. It\n works together with \u{1b}[32m--version\u{1b}[39m, to get the README of an older version,\n but not with \u{1b}[32m--versions\u{1b}[39m.\n\n \u{1b}[32m--readme --json\u{1b}[39m prints an object with the \u{1b}[32mpackage\u{1b}[39m and \u{1b}[32mversion\u{1b}[39m the\n README belongs to, the \u{1b}[32mreadme\u{1b}[39m itself, and the \u{1b}[32mformat\u{1b}[39m it is written\n in. The format is the one the repository reports, e.g. \u{1b}[32mmd\u{1b}[39m for markdown\n or \u{1b}[32mtxt\u{1b}[39m for plain text.\n\n A package without a README is not an error. \u{1b}[32m--readme\u{1b}[39m then prints\n nothing, and \u{1b}[32m--readme --json\u{1b}[39m prints \u{1b}[32mnull\u{1b}[39m for both \u{1b}[32mreadme\u{1b}[39m and\n \u{1b}[32mformat\u{1b}[39m.\n\n\u{1b}[1m\u{1b}[34mAll versions of a package:\u{1b}[39m\u{1b}[22m\n \u{1b}[32m--versions\u{1b}[39m lists all versions of the package ever published on CRAN,\n oldest first, instead of the details of a single version. For each version\n rig shows its publication date, its R version requirement and its number\n of hard dependencies (\u{1b}[32mDepends\u{1b}[39m, \u{1b}[32mImports\u{1b}[39m and \u{1b}[32mLinkingTo\u{1b}[39m, excluding R\n and the base packages); the latest version is marked. It cannot be\n combined with \u{1b}[32m--version\u{1b}[39m.\n\n For a package CRAN has archived, i.e. removed from the current\n repository, the header also shows the date it was archived. This applies\n to the package as a whole, so all of its versions are archived.\n\n \u{1b}[32m--versions --json\u{1b}[39m prints the full \u{1b}[32mDESCRIPTION\u{1b}[39m of every version, each\n with an extra \u{1b}[32mArchived\u{1b}[39m field for an archived package.";
4343
const ABOUT_PKG_INSTALL: &str = "Install packages from the repositories";
44-
const HELP_PKG_INSTALL: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Install one or more R packages, and everything they need, into an R package\n library.\n\n rig pkg install cli glue\n\n ✓ Solved dependencies\n 2 of 2 packages to install (R 4.4.1, main: /Users/gaborcsardi/Library/R/arm64/4.4/library)\n Package Version Type Action Reason\n cli 3.6.3 binary install not installed\n glue 1.8.0 binary install not installed\n ✓ Installed 2 packages (R 4.4.1, main: /Users/gaborcsardi/Library/R/arm64/4.4/library)\n\n rig resolves the whole dependency tree first, the same way\n \u{1b}[32mrig proj solve\u{1b}[39m does for a project, so a package is only\n installed if every package it needs can be installed with it, at versions\n that work together. \u{1b}[32m--dry-run\u{1b}[39m runs the resolution and reports what it\n would install, without installing anything.\n\n Package names are case sensitive, as they are in R. Naming the same package\n twice is not an error, it is installed once.\n\n\u{1b}[1m\u{1b}[34mBinary and source packages:\u{1b}[39m\u{1b}[22m\n A binary package is a package that has already been built for your platform\n and R version. Installing one is unpacking it into the library, so rig does\n that itself and never starts R.\n\n A package with no binary build is installed from its source tarball, with\n \u{1b}[32mR CMD INSTALL\u{1b}[39m, which does start R, and needs whatever that package needs\n to compile. The output of the compilation goes into a log file per package,\n in a \u{1b}[32m_logs\u{1b}[39m directory inside the library, and rig points at the log when an\n installation fails.\n\n \u{1b}[32m--platform\u{1b}[39m installs for a platform other than this machine's, and\n \u{1b}[32m--platform source\u{1b}[39m installs source packages only. \u{1b}[32m--prefer-binary\u{1b}[39m trades\n a newer version for an older one that has a binary build, which is useful\n when compiling is expensive; it takes the number of versions to look back\n through, e.g. \u{1b}[32m--prefer-binary=5\u{1b}[39m, and defaults to 3.\n\n\u{1b}[1m\u{1b}[34mWhat gets skipped:\u{1b}[39m\u{1b}[22m\n rig does not install a package that is already installed and up to date, so\n running the same command twice does nothing the second time.\n\n Being up to date is more than having the right version number. A repository\n can publish several builds of one version, and a package with compiled code\n only works with the versions of the packages it was compiled against — an R\n that loads a package built against a different one can crash rather than\n complain. So rig keeps track of which build each package it installs came\n from, and what that build was compiled against, and reinstalls a package\n whose build is no longer the one the resolution picked.\n\n That check cascades: replacing a package also replaces the packages that\n were compiled against it, and the packages compiled against those.\n\n rig only knows this about packages it installed itself, so a package that R,\n pak or renv installed is always reinstalled rather than assumed to match.\n \u{1b}[32m--reinstall\u{1b}[39m installs everything in the resolution regardless.\n\n\u{1b}[1m\u{1b}[34mWhich library:\u{1b}[39m\u{1b}[22m\n By default rig installs into the default library of the default R version,\n i.e. the library that \u{1b}[32mrig library default\u{1b}[39m reports, and the\n one R installs packages into.\n\n \u{1b}[32m--library\u{1b}[39m (\u{1b}[32m-l\u{1b}[39m) selects another library. It takes either the name of a\n library of the R version, as \u{1b}[32mrig library list\u{1b}[39m prints them,\n or the path of a library directory:\n\n rig pkg install --library myproject cli\n rig pkg install --library /usr/lib/R/site-library cli\n\n A path is used as it is, and is created if it does not exist yet, so it does\n not need to belong to an R version rig manages.\n\n \u{1b}[32m--r-version\u{1b}[39m (\u{1b}[32m-r\u{1b}[39m) selects the library of another R version, instead of\n the default one, as it does for the \u{1b}[32mrig library\u{1b}[39m commands.\n It has no effect on which library \u{1b}[32m--library\u{1b}[39m names when that is a path, but\n it still decides which binary packages fit, and which \u{1b}[32mR\u{1b}[39m installs a source\n package.\n\n In admin mode the site and system libraries of\n an R installation belong to the administrator, so installing into them needs\n \u{1b}[32msudo\u{1b}[39m (an administrator account on Windows). Your own user library never\n does.";
44+
const HELP_PKG_INSTALL: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Install one or more R packages, and everything they need, into an R package\n library.\n\n rig pkg install cli glue\n\n ✓ Solved dependencies\n 2 of 2 packages to install (R 4.4.1, main: /Users/gaborcsardi/Library/R/arm64/4.4/library)\n Package Version Type Action Reason\n cli 3.6.3 binary install not installed\n glue 1.8.0 binary install not installed\n ✓ Installed 2 packages (R 4.4.1, main: /Users/gaborcsardi/Library/R/arm64/4.4/library)\n\n rig resolves the whole dependency tree first, the same way\n \u{1b}[32mrig proj solve\u{1b}[39m does for a project, so a package is only\n installed if every package it needs can be installed with it, at versions\n that work together. \u{1b}[32m--dry-run\u{1b}[39m runs the resolution and reports what it\n would install, without installing anything.\n\n Package names are case sensitive, as they are in R. Naming the same package\n twice is not an error, it is installed once.\n\n\u{1b}[1m\u{1b}[34mDev dependencies:\u{1b}[39m\u{1b}[22m\n By default rig installs the hard dependencies only: \u{1b}[32mDepends\u{1b}[39m, \u{1b}[32mImports\u{1b}[39m\n and \u{1b}[32mLinkingTo\u{1b}[39m, i.e. the packages that need to be installed to use the\n package. \u{1b}[32m--dev\u{1b}[39m also installs the soft dependencies, \u{1b}[32mSuggests\u{1b}[39m and\n \u{1b}[32mEnhances\u{1b}[39m, which are typically only needed to run the tests, build the\n vignettes or use some optional feature.\n\n \u{1b}[32m--dev\u{1b}[39m applies to the packages named on the command line only. A dev\n dependency is installed with everything \u{1b}[3mit\u{1b}[23m needs to be installed, but not\n with its own dev dependencies, so \u{1b}[32m--dev\u{1b}[39m does not grow without bounds.\n\n A package often suggests packages that are not in the repositories rig\n installs from, e.g. Bioconductor packages. Those cannot be installed, and\n by default rig reports them and installs nothing.\n \u{1b}[32m--ignore-unavailable\u{1b}[39m installs the rest of the dev dependencies instead,\n and names the ones it skipped. It only applies to dev dependencies: a hard\n dependency that is not available is always an error, and so is a dev\n dependency that exists but has no version that fits.\n\n\u{1b}[1m\u{1b}[34mBinary and source packages:\u{1b}[39m\u{1b}[22m\n A binary package is a package that has already been built for your platform\n and R version. Installing one is unpacking it into the library, so rig does\n that itself and never starts R.\n\n A package with no binary build is installed from its source tarball, with\n \u{1b}[32mR CMD INSTALL\u{1b}[39m, which does start R, and needs whatever that package needs\n to compile. The output of the compilation goes into a log file per package,\n in a \u{1b}[32m_logs\u{1b}[39m directory inside the library, and rig points at the log when an\n installation fails.\n\n \u{1b}[32m--platform\u{1b}[39m installs for a platform other than this machine's, and\n \u{1b}[32m--platform source\u{1b}[39m installs source packages only. \u{1b}[32m--prefer-binary\u{1b}[39m trades\n a newer version for an older one that has a binary build, which is useful\n when compiling is expensive; it takes the number of versions to look back\n through, e.g. \u{1b}[32m--prefer-binary=5\u{1b}[39m, and defaults to 3.\n\n\u{1b}[1m\u{1b}[34mWhat gets skipped:\u{1b}[39m\u{1b}[22m\n rig does not install a package that is already installed and up to date, so\n running the same command twice does nothing the second time.\n\n Being up to date is more than having the right version number. A repository\n can publish several builds of one version, and a package with compiled code\n only works with the versions of the packages it was compiled against — an R\n that loads a package built against a different one can crash rather than\n complain. So rig keeps track of which build each package it installs came\n from, and what that build was compiled against, and reinstalls a package\n whose build is no longer the one the resolution picked.\n\n That check cascades: replacing a package also replaces the packages that\n were compiled against it, and the packages compiled against those.\n\n rig only knows this about packages it installed itself, so a package that R,\n pak or renv installed is always reinstalled rather than assumed to match.\n \u{1b}[32m--reinstall\u{1b}[39m installs everything in the resolution regardless.\n\n\u{1b}[1m\u{1b}[34mWhich library:\u{1b}[39m\u{1b}[22m\n By default rig installs into the default library of the default R version,\n i.e. the library that \u{1b}[32mrig library default\u{1b}[39m reports, and the\n one R installs packages into.\n\n \u{1b}[32m--library\u{1b}[39m (\u{1b}[32m-l\u{1b}[39m) selects another library. It takes either the name of a\n library of the R version, as \u{1b}[32mrig library list\u{1b}[39m prints them,\n or the path of a library directory:\n\n rig pkg install --library myproject cli\n rig pkg install --library /usr/lib/R/site-library cli\n\n A path is used as it is, and is created if it does not exist yet, so it does\n not need to belong to an R version rig manages.\n\n \u{1b}[32m--r-version\u{1b}[39m (\u{1b}[32m-r\u{1b}[39m) selects the library of another R version, instead of\n the default one, as it does for the \u{1b}[32mrig library\u{1b}[39m commands.\n It has no effect on which library \u{1b}[32m--library\u{1b}[39m names when that is a path, but\n it still decides which binary packages fit, and which \u{1b}[32mR\u{1b}[39m installs a source\n package.\n\n In admin mode the site and system libraries of\n an R installation belong to the administrator, so installing into them needs\n \u{1b}[32msudo\u{1b}[39m (an administrator account on Windows). Your own user library never\n does.";
4545
const ABOUT_PKG_LIST: &str = "Packages installed in a library";
4646
const HELP_PKG_LIST: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the packages installed in an R package library, without starting R.\n\n 312 packages (R 4.4.1, main: /Users/gaborcsardi/Library/R/arm64/4.4/library)\n\n Package Version Built Platform Source\n -----------------------------------------------------------------------------\n cli 3.6.3 4.4.0 aarch64-apple-darwin20 CRAN\n glue 1.8.0 4.4.1 aarch64-apple-darwin20 CRAN\n asciicast 2.3.1.9000 4.4.1 aarch64-apple-darwin20 github::r-lib/asciicast\n mypkg 0.0.1 4.4.1 - -\n\n The first line names the number of packages and the library they were found\n in. Each line below it names a package, its version, the R version it was\n built for, the platform it was built for, and where it was installed from.\n\n \u{1b}[32mPlatform\u{1b}[39m is empty for a package installed from source. \u{1b}[32mSource\u{1b}[39m is the\n repository the package came from, e.g. \u{1b}[32mCRAN\u{1b}[39m, and for a package installed\n from somewhere else it names that place instead, in the package reference\n syntax pak uses: \u{1b}[32mgithub::<user>/<repo>\u{1b}[39m for a GitHub install, \u{1b}[32mgit::<url>\u{1b}[39m\n for a git one, and so on. It is empty for a package installed from a local\n directory, as \u{1b}[32mR CMD INSTALL\u{1b}[39m and \u{1b}[32mdevtools::install()\u{1b}[39m do, because such a\n package records nothing about where its source was.\n\n A field the package's \u{1b}[32mDESCRIPTION\u{1b}[39m does not have is shown as \u{1b}[32m-\u{1b}[39m. Use\n \u{1b}[32m--json\u{1b}[39m for machine readable output, which reports the repository or remote\n type as \u{1b}[32msource\u{1b}[39m and the remote itself as \u{1b}[32mremote\u{1b}[39m, separately.\n\n This subcommand and \u{1b}[32mrig pkg remove\u{1b}[39m read an \u{1b}[3minstalled\u{1b}[23m\n library; the others, e.g. \u{1b}[32mrig pkg available\u{1b}[39m, read the\n package repositories that packages are installed \u{1b}[3mfrom\u{1b}[23m.\n\n\u{1b}[1m\u{1b}[34mWhich library:\u{1b}[39m\u{1b}[22m\n By default rig lists the default library of the default R version, i.e. the\n library that \u{1b}[32mrig library default\u{1b}[39m reports, and the one R\n installs packages into.\n\n \u{1b}[32m--library\u{1b}[39m (\u{1b}[32m-l\u{1b}[39m) selects another library. It takes either the name of a\n library of the R version, as \u{1b}[32mrig library list\u{1b}[39m prints them, or\n the path of a library directory:\n\n rig pkg list --library myproject\n rig pkg list --library /usr/lib/R/site-library\n\n A path is used as it is, so it does not need to belong to an R version rig\n manages, and rig does not need an R version at all to list it.\n\n \u{1b}[32m--r-version\u{1b}[39m (\u{1b}[32m-r\u{1b}[39m) lists the library of another R version, instead of the\n default one, as it does for the \u{1b}[32mrig library\u{1b}[39m commands. It has\n no effect when \u{1b}[32m--library\u{1b}[39m is a path.\n\n Subdirectories that are not packages are left out: rig's own libraries of a\n main library, and the leftovers of an interrupted installation.";
4747
const ABOUT_PKG_REMOVE: &str = "Remove packages from a library";

src/help/pkg-install.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ would install, without installing anything.
2727
Package names are case sensitive, as they are in R. Naming the same package
2828
twice is not an error, it is installed once.
2929

30+
## Dev dependencies
31+
32+
By default rig installs the hard dependencies only: `Depends`, `Imports`
33+
and `LinkingTo`, i.e. the packages that need to be installed to use the
34+
package. `--dev` also installs the soft dependencies, `Suggests` and
35+
`Enhances`, which are typically only needed to run the tests, build the
36+
vignettes or use some optional feature.
37+
38+
`--dev` applies to the packages named on the command line only. A dev
39+
dependency is installed with everything *it* needs to be installed, but not
40+
with its own dev dependencies, so `--dev` does not grow without bounds.
41+
42+
A package often suggests packages that are not in the repositories rig
43+
installs from, e.g. Bioconductor packages. Those cannot be installed, and
44+
by default rig reports them and installs nothing.
45+
`--ignore-unavailable` installs the rest of the dev dependencies instead,
46+
and names the ones it skipped. It only applies to dev dependencies: a hard
47+
dependency that is not available is always an error, and so is a dev
48+
dependency that exists but has no version that fits.
49+
3050
## Binary and source packages
3151

3252
A binary package is a package that has already been built for your platform

0 commit comments

Comments
 (0)