I have a program that depends on two packages that I frequently develop in conjunction: pkg1 which is a dependency for pkg2.
The main program refers to pkg2 only ... and thus pkg1 exists only via the bindings pkg2 creates to it. For example, there exists some pkg2 function:
do_something() {
pkg1::actually_do_something()
}
To ease development, I put in a relatively basic switch that checks an environment variable to load the development version via devtools::load_all(), saving me from needing to repeatedly build/install while actively developing:
if (isTRUE(Sys.getenv("MYENV") == "DEV")) {
devtools::load_all("path/to/pkg2")
} else {
library(pkg2)
}
This all works fine until I make a change in pkg1 that's needed for pkg2. In such cases, I've found myself needing to install pkg1 while developing (possibly only temporarily, e.g. via devtools::dev_mode()). Without that installation step, any updated code in pkg2 uses the previously installed version of pkg1, but as I mentioned above, I tend to make package updates to both in synchronicity. This negates some advantage of the switch above because now I need to repeatedly need to build/install pkg1 when making quick development changes.
Is there a pattern that I haven't discovered where I can 'register' the path to pkg1 as a temporary path for the in-development version of pkg2 to use instead of the current R session's library-installed version of pkg1? Something like devtools::load_all(), but only importing the package, not fully attaching the package (while also routing dependent packages to this imported version instead of the original somehow).
Also important, I suppose: I'd like to avoid adding pkg1 as a direct dependency of the main program (i.e. not doing devtools::load_all("path/to/pkg1")) as it doesn't reflect the production version of the program which only needs to take the pkg2 direct dependency via the single library(pkg2) call.