Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build_site failure with examples #2746

Closed
TheZetner opened this issue Aug 2, 2024 · 9 comments
Closed

Build_site failure with examples #2746

TheZetner opened this issue Aug 2, 2024 · 9 comments

Comments

@TheZetner
Copy link

I've found after updating pkgdown from 2.0.9 to 2.1.0 that site building fails on the build_reference step when I have examples in my Rd documents. These failures go away when I delete the examples and persist even if the examples are labelled with \dontrun{} or commented out in the roxygen headers (#' # examplecode).

I've debugged fairly deeply into the nested functions of build_site() (build_reference > build_reference_topic > data_reference_topic > run_examples) but frankly was out of my depth by the lowest point there.

The error I've been getting is:

Error: 
! in callr subprocess.
Caused by error in `build_reference()`:
! Failed to parse Rd in escServer.Rd
Caused by error in `output_handler$source()`:
! argument "expr" is missing, with no default
ℹ See `$stdout` and `$stderr` for standard output and error.
Type .Last.error to see the more details.

.lastError returns the following:

> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! in callr subprocess.
Caused by error in `build_reference()`:
! Failed to parse Rd in escServer.Rd
Caused by error in `output_handler$source()`:
! argument "expr" is missing, with no default
ℹ See `$stdout` and `$stderr` for standard output and error.
---
Backtrace:
1. pkgdown::build_site()
2. pkgdown:::build_site_external(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
3. callr::r(function(..., cli_colors, hyperlinks, pkgdown_internet) { …
4. callr:::get_result(output = out, options)
5. callr:::throw(callr_remote_error(remerr, output), parent = fix_msg(remerr[[3]]))
---
Subprocess backtrace:
 1. pkgdown::build_site(...)
 2. pkgdown:::build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
 3. pkgdown::build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_dont_run, …
 4. pkgdown:::unwrap_purrr_error(purrr::map(topics, build_reference_topic, …
 5. base::withCallingHandlers(code, purrr_error_indexed = function(err) { …
 6. purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, …
 7. purrr:::map_("list", .x, .f, ..., .progress = .progress)
 8. purrr:::with_indexed_errors(i = i, names = names, error_call = .purrr_error_call, …
 9. base::withCallingHandlers(expr, error = function(cnd) { …
10. purrr:::call_with_cleanup(map_impl, environment(), .type, .progress, …
11. local .f(.x[[i]], ...)
12. base::withCallingHandlers(data_reference_topic(topic, pkg, examples_env = examples_env, …
13. pkgdown:::data_reference_topic(topic, pkg, examples_env = examples_env, …
14. pkgdown:::run_examples(tags$tag_examples[[1]], env = if (is.null(examples_env)) NULL else new.env(parent = examples_env), …
15. pkgdown:::highlight_examples(code, topic, env = env)
16. downlit::evaluate_and_highlight(code, fig_save = fig_save_topic, …
17. evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
18. evaluate:::evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, …
19. output_handler$source(source)
20. base::.handleSimpleError(function (err) …
21. local h(simpleError(msg, call))
22. cli::cli_abort("Failed to parse Rd in {.file {topic$file_in}}", …
23. | rlang::abort(message, ..., call = call, use_cli_format = TRUE, …
24. | rlang:::signal_abort(cnd, .file)
25. | base::signalCondition(cnd)
26. (function (cnd) …
27. cli::cli_abort(message, location = i, name = name, parent = cnd, …
28. | rlang::abort(message, ..., call = call, use_cli_format = TRUE, …
29. | rlang:::signal_abort(cnd, .file)
30. | base::signalCondition(cnd)
31. (function (err) …
32. rlang::cnd_signal(err$parent)
33. rlang:::signal_abort(cnd)
34. base::signalCondition(cnd)
35. global (function (e) …

I've made a branch showing this behaviour in a very small package here: https://github.com/TheZetner/esckey/tree/failingbuild

For now I'm just cutting the examples (as they're super minimal for esckey) but this is an issue for rebuilding my more complex sites where I've simply reverted to pkgdown 2.0.9.

Lastly I love this package! I've used it for several packages now and it just makes documentation and presentation a breeze. Thanks for it!

Cheers,
Adrian

@TheZetner TheZetner changed the title Build_site failure with shiny examples Build_site failure with examples Aug 2, 2024
@TheZetner
Copy link
Author

Confirmed this fails non-shiny examples as well

@jayhesselberth
Copy link
Collaborator

I'm unable to reproduce this error, your package and site builds fine on my machine.

Can you try running pkgdown::clean_site() and pkgdown::clean_cache(), devtools::document(), and then re-build?

@TheZetner
Copy link
Author

After clean_site it's now working fine on both packages. Thanks for the quick response!

I'll be sure to clean site if I see any weird errors in the future. I didn't run clean_cache() as it's not in pkgdown, was that from a different package?

@jayhesselberth
Copy link
Collaborator

oops, clean_cache() is only in dev pkgdown.

@TheZetner
Copy link
Author

I started having weird issues again with 2.1.0, traced it to something deep in build_home() calling print_yaml() with some mentions of cache in .Last.error. Installed dev version, cleaned cache, and now it's working perfectly. So thanks for mentioning clean_cache as a dev option!!

@cpauvert
Copy link

Hey! First of all, thanks for the awesome on-ongoing work with the package, that keep bringing documentation easily to every useRs! ❤️

I've also experienced the same issue as @TheZetner as in the first message. Bumping to dev version (ee72108) and using clean_site() and clean_cache() restart repeatedly did not solve.
Running build_site(examples = FALSE) does not trigger the error.

Regarding YAML files, I did needed to bump yaml from v2.3.7 to v2.3.8 as 'verbatim_logical' is not an exported object from 'namespace:yaml' but your issue seems different in that regard @TheZetner

Best,

@hadley
Copy link
Member

hadley commented Sep 12, 2024

Start by installing the latest version of httr2.

@lz100
Copy link

lz100 commented Oct 13, 2024

@jayhesselberth @hadley I'm having the same error, with pkgdown 2.1.1, httr2 1.0.5.

I run pkgdown::clean_site(), pkgdown::clean_cache(), devtools::document() before building the reference,
but it didn't help.

# > pkgdown::build_reference()
Error in `build_reference()`:
! Failed to parse Rd in a_test_function.Rd
Caused by error in `output_handler$source()`:
! argument "expr" is missing, with no default
Backtrace:1. ├─pkgdown::build_reference()
  2. │ ├─pkgdown:::unwrap_purrr_error(...) at pkgdown/R/build-reference.R:188:3
  3. │ │ └─base::withCallingHandlers(...) at pkgdown/R/utils.R:39:3
  4. │ └─purrr::map(...) at pkgdown/R/build-reference.R:188:3
  5. │   └─purrr:::map_("list", .x, .f, ..., .progress = .progress) at purrr/R/map.R:129:3
  6. │     ├─purrr:::with_indexed_errors(...) at purrr/R/map.R:174:3
  7. │     │ └─base::withCallingHandlers(...) at purrr/R/map.R:201:3
  8. │     ├─purrr:::call_with_cleanup(...) at purrr/R/map.R:174:3
  9. │     └─pkgdown (local) .f(.x[[i]], ...)
 10. │       ├─base::withCallingHandlers(...) at pkgdown/R/build-reference.R:280:3
 11. │       └─pkgdown:::data_reference_topic(...) at pkgdown/R/build-reference.R:280:3
 12. │         └─pkgdown:::run_examples(...) at pkgdown/R/build-reference.R:367:5
 13. │           └─pkgdown:::highlight_examples(code, topic, env = env) at pkgdown/R/rd-example.R:36:5
 14. │             └─downlit::evaluate_and_highlight(...) at pkgdown/R/highlight.R:57:3
 15. │               └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler) at downlit/R/evaluate.R:46:3
 16. │                 └─evaluate:::evaluate_call(...)
 17. │                   └─output_handler$source(source)
 18. └─base::.handleSimpleError(...) at pkgdown/R/highlight.R:32:5
 19.   └─pkgdown (local) h(simpleError(msg, call))
 20.     └─cli::cli_abort(...) at pkgdown/R/build-reference.R:288:7
 21.       └─rlang::abort(...) at cli/R/rlang.R:45:3

If I don't run the examples, it worked fine build_reference(examples = FALSE). The function is very simple

#' test func
#' @export
#' @return NULL
#' @examples
#' 1 + 1
a_test_function <- function() {}
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] myPkg_0.0.99 testthat_3.2.1.1 

loaded via a namespace (and not attached):
 [1] xfun_0.45           bslib_0.7.0         htmlwidgets_1.6.4   devtools_2.4.5      remotes_2.5.0       gargle_1.5.2        tzdb_0.4.0          vctrs_0.6.5        
 [9] tools_4.4.1         generics_0.1.3      tibble_3.2.1        fansi_1.0.6         pkgconfig_2.0.3     desc_1.4.3          lifecycle_1.0.4     compiler_4.4.1     
[17] stringr_1.5.1       textshaping_0.4.0   brio_1.1.5          fontawesome_0.5.2   httpuv_1.6.15       htmltools_0.5.8.1   usethis_2.2.3       sass_0.4.9         
[25] yaml_2.3.8          later_1.3.2         pillar_1.9.0        pkgdown_2.1.1       jquerylib_0.1.4     urlchecker_1.0.1    whisker_0.4.1       tidyr_1.3.1        
[33] ellipsis_0.3.2      openssl_2.2.0       googlesheets4_1.1.1 cachem_1.1.0        sessioninfo_1.2.2   mime_0.12           tidyselect_1.2.1    digest_0.6.35      
[41] stringi_1.8.3       dplyr_1.1.4         purrr_1.0.2         rprojroot_2.0.4     fastmap_1.2.0       cli_3.6.3           magrittr_2.0.3      pkgbuild_1.4.4     
[49] utf8_1.2.4          readr_2.1.5         withr_3.0.0         promises_1.3.0      googledrive_2.1.1   rmarkdown_2.27      cellranger_1.1.0    askpass_1.2.0      
[57] ragg_1.3.2          chk_0.9.2           hms_1.1.3           memoise_2.0.1       shiny_1.8.1.1       evaluate_0.23       knitr_1.48          miniUI_0.1.1.1     
[65] profvis_0.3.8       rlang_1.1.4         downlit_0.4.4       Rcpp_1.0.12         xtable_1.8-4        glue_1.8.0          xml2_1.3.6          renv_1.0.7         
[73] pkgload_1.3.4       rstudioapi_0.16.0   jsonlite_1.8.8      R6_2.5.1            systemfonts_1.1.0   fs_1.6.4      

@lz100
Copy link

lz100 commented Oct 13, 2024

I managed to fix it by upgrading evaluate according to this issue #2740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants