1

I am using packrat in an R project, and it is rather laborious to add functions to my custom package, rebuild, push to GitHub, and then re-download the package from GitHub into packrat. Besides taking a lot of extra time this involves pushing my new functions to the master, which is not ideal when I'm still iterating on new functions.

If I were not using packrat I could just rebuild the package locally, restart R and the updated version of the package would be accessible.

Is there a way to speed up this workflow and still use packrat?

Joe
  • 3,217
  • 3
  • 21
  • 37

2 Answers2

1

Here is how I installed a locally built package in packrat:

After building the package locally from RStudio, a path was displayed in the Build tab:

* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’

Copy this path along with the package name and return to your project that is using packrat. In the console enter:

path_to_my_locally_built_package <- "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/my_package"

devtools::install(path_to_my_locally_built_package)

library(my_package)

Your local package will now be in packrat and all of its functions will be available for use.

Joe
  • 3,217
  • 3
  • 21
  • 37
  • Future viewers may find it necessary to add in the fix suggested [here](https://github.com/rstudio/packrat/issues/379): `options(pkgType = "source")`. – eric_kernfeld Aug 19 '19 at 13:31
0

Is there a reason not to do what the packrat folks recommend?

packrat::set_opts(local.repos = c("path/to/my/packages"))
packrat::install_local("mypackage")
eric_kernfeld
  • 495
  • 5
  • 17