:fire: A friendly package manager for R
Inspired by Yarn, Bundler, and Pipenv
Install Jetpack
install.packages("jetpack")
Jetpack uses the DESCRIPTION
file to store your project
dependencies. It stores the specific version of each package in
renv.lock
. This makes it possible to have a reproducible
environment. You can edit dependencies in the DESCRIPTION
file directly, but Jetpack provides functions to help with this.
Open a project and run:
::init() jetpack
Install packages for a project
::install() jetpack
This ensures all the right versions are installed locally. As dependencies change, collaborators should run this command to stay synced.
Be sure to prefix commands with
jetpack::
. Jetpack isn’t installed in your virtual environment, solibrary(jetpack)
won’t work.
Add a package
::add("randomForest") jetpack
Add multiple packages
::add(c("randomForest", "DBI")) jetpack
Add a specific version
::add("DBI@1.0.0") jetpack
Add from GitHub or another remote source
::add("plyr", remote="hadley/plyr") jetpack
Supports these remotes
Add from a specific tag, branch, or commit
::add("plyr", remote="hadley/plyr@v1.8.4") jetpack
Add from a local source
::add("plyr", remote="local::/path/to/plyr") jetpack
The local directory must have the same name as the package
Update a package
::update("randomForest") jetpack
For local packages, run this anytime the package code is changed
Update multiple packages
::update(c("randomForest", "DBI")) jetpack
Update all packages
::update() jetpack
Remove a package
::remove("randomForest") jetpack
Remove multiple packages
::remove(c("randomForest", "DBI")) jetpack
Remove remotes as well
::remove("plyr", remote="hadley/plyr") jetpack
Check that all dependencies are installed
::check() jetpack
Show outdated packages
::outdated() jetpack
Be sure to commit the files Jetpack generates to source control.
For Bioconductor, add the BiocManager package first:
::add("BiocManager") jetpack
Then add other packages:
::add("Biobase", remote="bioc::release/Biobase") jetpack
Install Jetpack on the server and run:
::install(deployment=TRUE) jetpack
Create init.R
with:
install.packages("jetpack")
::install(deployment=TRUE) jetpack
And add it into your Dockerfile
:
FROM r-base
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
libxml2-dev libssl-dev libcurl4-openssl-dev libssh2-1-dev
RUN mkdir -p /app
WORKDIR /app
COPY init.R DESCRIPTION renv.lock ./
RUN Rscript init.R
COPY . .
CMD Rscript app.R
For the R
buildpack, create init.R
with:
install.packages("jetpack")
::install(deployment=TRUE) jetpack
Alternatively, you can use Docker Deploys on Heroku.
Jetpack can also be run from the command line. To install the CLI, run:
::cli() jetpack
On Windows, add
C:\ProgramData\jetpack\bin
to your PATH. See instructions for how to do this.
All the Jetpack commands are now available
jetpack init
jetpack install
jetpack add randomForest
jetpack add DBI@1.0.0
jetpack add plyr --remote=hadley/plyr
jetpack update randomForest
jetpack remove DBI
jetpack check
jetpack outdated
You can also use it to manage global packages
jetpack global add randomForest
jetpack global update DBI
jetpack global update
jetpack global remove plyr
jetpack global list
jetpack global outdated
You can even use it to update itself
jetpack global update jetpack
For the full list of commands, use:
jetpack help
To upgrade, rerun the installation instructions.
Jetpack 0.5.0 uses renv instead of Packrat. To upgrade a project:
jetpack::migrate()
packrat.lock
jetpack::install()
Jetpack 0.4.0 greatly reduces the number of dependencies. As part of
this, the info
and search
commands have been
removed.
Jetpack 0.3.0 greatly reduces the number of files in your projects. To upgrade a project:
packrat/packrat.lock
to
packrat.lock
packrat
directory.Rbuildignore
and .gitignore
if
they only contain Packrat references.Rprofile
with:if (requireNamespace("jetpack", quietly=TRUE)) {
::load()
jetpackelse {
} message("Install Jetpack to use a virtual environment for this project")
}
::install() jetpack
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
To get started with development and testing:
git clone https://github.com/ankane/jetpack.git
cd jetpack
In R, do:
install.packages("devtools")
::install_deps(dependencies=TRUE)
devtools::test() devtools
To test a single file, use:
::install() # to use latest updates
devtools::test_active_file("tests/testthat/test-jetpack.R") devtools