TheoMichelot / hmmTMB

Fit hidden Markov models using Template Model Builder (TMB): flexible state-dependent distributions, transition probability structures, random effects, and smoothing splines.
53 stars 7 forks source link

Roxygen not working #3

Closed TheoMichelot closed 3 years ago

TheoMichelot commented 3 years ago

The command devtools::document() fails with the following error:

Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection

I include the traceback below; it looks like the error occurs when trying to load distnames.RData in dist.R:

17. readChar(con, 5L, useBytes = TRUE) 
16. load(paste0(find.package("hmmTMB"), "/distnames.RData")) at dist.R#48
15. initialize(...) 
14. Dist$new(name = "pois", pdf = dpois, rng = rpois, link = list(lambda = log), 
    invlink = list(lambda = exp), npar = 1) at dist_def.R#7
13. eval(exprs[i], envir) 
12. eval(exprs[i], envir) 
11. source_one(file, encoding, envir = envir) 
10. source_many(paths, encoding, env) 
9. force(code) 
8. withr_with_dir(path, source_many(paths, encoding, env)) 
7. load_code(path) 
6. pkgload::load_all(path, helpers = FALSE, attach_testthat = FALSE) 
5. load_code(base_path) 
4. roxygen2::roxygenise(pkg$path, roclets, load_code = load_code) 
3. force(code) 
2. withr::with_envvar(r_env_vars(), roxygen2::roxygenise(pkg$path, 
    roclets, load_code = load_code)) 
1. devtools::document() 
TheoMichelot commented 3 years ago

I managed to temporarily circumvent this problem by copying distnames.RData to the root of the package on my machine, and then run devtools::document(). We need to come up with a long-term solution.

TheoMichelot commented 3 years ago

I wrote a small update_doc function in inst/util.R, which creates a temporary copy of distnames.RData at the root of the package, then runs devtools::document, then removes the copy.