Manage project dependencies from your DESCRIPTION file. Create a reproducible virtual environment with minimal additional files in your project. Provides tools to add, remove, and update dependencies as well as install existing dependencies with a single function.
🔥 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 packrat.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:
jetpack::init()
Install packages for a project
jetpack::install()
This ensures all the right versions are installed locally. As dependencies change, collaborators should run this command to stay synced.
Add a package
jetpack::add("randomForest")
Add multiple packages
jetpack::add(c("randomForest", "DBI"))
Add a specific version
jetpack::add("[email protected]")
Add from GitHub or another remote source
jetpack::add("plyr", remote="hadley/plyr")
Supports these remotes
Add from a specific tag, branch, or commit
jetpack::add("plyr", remote="hadley/[email protected]")
Add from a local source
jetpack::add("plyr", remote="local::/path/to/plyr")
The local directory must have the same name as the package
Update a package
jetpack::update("randomForest")
For local packages, run this anytime the package code is changed
Update multiple packages
jetpack::update(c("randomForest", "DBI"))
Update all packages
jetpack::update()
Remove a package
jetpack::remove("randomForest")
Remove multiple packages
jetpack::remove(c("randomForest", "DBI"))
Remove remotes as well
jetpack::remove("plyr", remote="hadley/plyr")
Check that all dependencies are installed
jetpack::check()
Show outdated packages
jetpack::outdated()
Be sure to commit the files Jetpack generates to source control.
Install Jetpack on the server and run:
jetpack::install(deployment=TRUE)
Create an init.R
with:
install.packages("jetpack")jetpack::install(deployment=TRUE)
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 /appWORKDIR /app COPY init.R DESCRIPTION packrat.lock ./RUN Rscript init.R COPY . . CMD Rscript app.R
There’s ongoing work to get Packrat working with the R buildpack.
In the meantime, you can use Docker Deploys on Heroku.
Jetpack can also be run from the command line. To install the CLI, run:
jetpack::cli()
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 initjetpack installjetpack add randomForestjetpack add [email protected]jetpack add plyr --remote=hadley/plyrjetpack update randomForestjetpack remove DBIjetpack checkjetpack outdated
You can also use it to manage global packages
jetpack global add randomForestjetpack global update DBIjetpack global updatejetpack global remove plyrjetpack global listjetpack 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.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)) { jetpack::load()} else { message("Install Jetpack to use a virtual environment for this project")}
jetpack::install()
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.gitcd jetpack
In R, do:
install.packages("devtools")devtools::install_deps(dependencies=TRUE)devtools::test()
jetpack::outdated()
jetpack global outdated
jetpack::install()
updating package versions in packrat.lock
when library gets aheadBreaking changes
info
and search
commands to reduce dependencies