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

Using in-body syntax for knitr chunk options creates problems for pkgdown in presence of child documents #2168

Closed
IndrajeetPatil opened this issue Jul 21, 2022 · 14 comments

Comments

@IndrajeetPatil
Copy link
Contributor

While converting from the in-header chunk option syntax to new the in-body syntax, I have noticed that this new syntax trips up {pkgdown}'s vignette rendering when child documents are present.

For a minimal reprex, see this PR:
IndrajeetPatil/minimalReprex#3

When I try to build the website locally, I see the following backtrace:

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, pkgdown_internet) { …
4. callr:::get_result(output = out, options)
5. callr:::throw(callr_remote_error(remerr))
6. callr:::callr_remote_error(remerr)
7. callr:::throw(err, parent = 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_articles(pkg, lazy = lazy, override = override, preview = FALSE)
 4. purrr::walk(pkg$vignettes$name, build_article, pkg = pkg, quiet = quiet, …
 5. purrr::map(.x, .f, ...)
 6. local .f(.x[[i]], ...)
 7. pkgdown:::render_rmarkdown(pkg, input = input, output = output_file, output_format = format, …
 8. base::tryCatch(callr::r_safe(function(...) rmarkdown::render(...), …
 9. base::tryCatchList(expr, classes, parentenv, handlers)
10. base::tryCatchOne(expr, names, parentenv, handlers[[1L]])
11. value[[3L]](cond)
12. rlang::abort("Failed to render RMarkdown", parent = cnd)
13. | rlang:::signal_abort(cnd, .file)
14. | base::signalCondition(cnd)
15. global (function (e) …
@maelle
Copy link
Collaborator

maelle commented Jul 22, 2022

👋 @IndrajeetPatil! Thanks for the reprex and bug report.

Setting a browser() deeply enough in the functions I get the actual error message!

Quitting from lines 12-13 (/tmp/RtmpeywYCq/../man/rmd-fragments/boilerplate.Rmd) 
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/tmp/RtmpeywYCq/../man/rmd-fragments/boilerplate.Rmd': No such file or directory

🤔

@IndrajeetPatil
Copy link
Contributor Author

Thanks for digging into this!

This is strange. Why does this happen only with in-body syntax?

cannot open file '/tmp/RtmpeywYCq/../man/rmd-fragments/boilerplate.Rmd': No such file or directory

The child document is there and {pkgdown} works fine on the main branch where in-header chunk option is used to specify child document.

@maelle
Copy link
Collaborator

maelle commented Jul 22, 2022

btw shouldn't the syntax for the in-body option be

#| child: "../man/rmd-fragments/boilerplate.Rmd"

Sadly it does not make the problem go away.

@maelle
Copy link
Collaborator

maelle commented Jul 22, 2022

ah no your syntax is the correct one anyway

@IndrajeetPatil
Copy link
Contributor Author

Btw, I used the new {knitr} function to convert the old syntax to the new syntax.

@maelle
Copy link
Collaborator

maelle commented Jul 22, 2022

oh good to know about, thank you!

@maelle
Copy link
Collaborator

maelle commented Jul 22, 2022

I wonder if somehow the problem could be linked to https://github.com/yihui/knitr/blob/553b6929f0b737f02fffc20cd10a10d0268b1487/NEWS.md?plain=1#L234

I'm stuck so will leave this aside for now.

@maelle
Copy link
Collaborator

maelle commented Jul 25, 2022

Posting the whole trace

Quitting from lines 12-13 (/tmp/RtmpXwp60l/../man/rmd-fragments/boilerplate.Rmd) 
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/tmp/RtmpXwp60l/../man/rmd-fragments/boilerplate.Rmd': No such file or directory
Backtrace:
  1. knitr::knit(..., tangle = TRUE)
  2. knitr:::process_file(text, output)
  5. knitr:::process_tangle.block(group)
  6. base::lapply(sc_split(params$child), knit_child)
  7. knitr (local) FUN(X[[i]], ...)
  8. knitr::knit(..., tangle = opts_knit$get("tangle"), envir = envir)
  9. xfun::read_utf8(input)
 10. base::readLines(con, encoding = "UTF-8", warn = FALSE)
 11. base::file(con, "r")

@maelle
Copy link
Collaborator

maelle commented Jul 25, 2022

I see the same error with rmarkdown::render("vignettes/test2.Rmd", intermediates_dir = tempdir())

@IndrajeetPatil
Copy link
Contributor Author

Thanks for digging deeper!

Do you think this is {rmarkdown} issue then?

@maelle
Copy link
Collaborator

maelle commented Jul 25, 2022

I think so, I'm about to open an issue, I'm 99% I found the problem 😸

@maelle
Copy link
Collaborator

maelle commented Jul 25, 2022

rstudio/rmarkdown#2393

@IndrajeetPatil
Copy link
Contributor Author

Thanks! Closing this issue in favour of that issue then :)

@maelle
Copy link
Collaborator

maelle commented Jul 25, 2022

And we'll re-open if I'm wrong there 😅

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

2 participants