Executes a package installation command so that the installed package will be aware of the modules you currently have loaded. This means you can load the package without needing to load that module later, and also that you can load that package now, without restarting your R session.
Arguments
- expr
Any R code you want to run that installs packages. Most of the time this will just be a call to install.packages
Details
This functionality is performed by setting a temporary value of
the LDFLAGS environment variable in your Makevars file. It will not work
if the R package is not set up to correctly use LDFLAGS, but all
correctly configured R packages will automatically do so.
It is recommended that you have only the minimal number of modules
needed to install this package loaded when you run this.
It is also recommended that you use utils::install.packages()
with the
utils
namespace qualifier, because RStudio patches this function in an
incompatible way.
Examples
options(repos=c(CRAN="https://cloud.r-project.org/"))
module_load("hdf5")
#> ✔ Successfully loaded hdf5
utils::install.packages("hdf5r") |> with_module_install()
#> Installing package into ‘/vast/scratch/users/milton.m/Rtmpt8rHU9/temp_libpath5ffb33f876a3’
#> (as ‘lib’ is unspecified)