PredictiveEcology / reproducible

A set of tools for R that enhance reproducibility beyond package management
https://reproducible.predictiveecology.org/
40 stars 13 forks source link

preProcess fails when `terra` not installed and `fun = NA` #393

Open CeresBarros opened 4 weeks ago

CeresBarros commented 4 weeks ago

This is a terrible reprex, but more so I don't forget about it:

remove.packages("terra")
repos <- c("predictiveecology.r-universe.dev", getOption("repos"))
install.packages(c("SpaDES.project", "googledrive", "reproducible"), 
                 repos = repos)
library(SpaDES.project)

## get Castor modules and functions
setupFunctions(paths = list("projectPath" = "~/"),
               functions = c("PredictiveEcology/PredictiveEcology.org@main/tutos/castorExample/getCastorModulesAndDB.R",
                             "PredictiveEcology/PredictiveEcology.org@main/tutos/castorExample/params.R"),
               overwrite = TRUE)
outMod <- getCastorModulesAndDB(paths = list("modulePath" = "~/tutos/castorExample/modules/",
                                             "projectPath" = "~/tutos/castorExample"),
                                modules = c("dataCastor", 
                                            "growingStockCastor", 
                                            "forestryCastor", 
                                            "blockingCastor"),
                                dbURL = "https://drive.google.com/file/d/1-2POunzC7aFbkKK5LeBJNsFYMBBY8dNx/view?usp=sharing",
                                dbPath = "~/tutos/castorExample/R/scenarios/comparison_stsm")

tracked down to:

Browse[3]> 
debug: feKnown <- .fileExtsKnown()
Browse[3]> 
Error in loadNamespace(x) : there is no package called ‘terra’
debug: unlink(.tempPath, recursive = TRUE)
achubaty commented 3 weeks ago

Isn't this an issue with SpaDES.project, rather than reproducible? If terra is removed, then reproducible (re)installed (with dependencies = TRUE to get the suggested packages, including terra), then it should pick up the suggested terra dependency.

THat said, this may suggest a problem with the conditional use of terra.