Skip to content

rmarkdown::site_generator() can hang session waiting for input #2043

Closed

Description

@kevinushey

To reproduce:

contents <- "

```{r}
library(bookdown)
```

--- 
site: bookdown::bookdown_site
---

```
"

dir <- tempfile("rmarkdown-repro-")
dir.create(dir)
writeLines(contents, con = file.path(dir, "index.Rmd"))

rmarkdown::site_generator(dir)

After running this code, the R console will be busy waiting for input from the user:

Screen Shot 2021-02-10 at 4 31 31 PM

It looks like this happens because rmarkdown inadvertently calls parse(text = NULL) here:

create_site_generator <- eval(parse(text = front_matter$site))

It might be possible to trigger this bug in a couple other places where parse(text = ...) is used:

$ rg -F 'parse(text'
R/html_resources.R
335:  output_format_function <- eval(parse(text = output_format$name))

R/render_site.R
270:  create_site_generator <- eval(parse(text = front_matter$site))

R/output_format.R
401:  format_function <- eval(parse(text = format$name))
599:  output_format_func <- eval(parse(text = name))

R/shiny_prerendered.R
31:    eval(parse(text = server_start_context), envir = server_envir)
42:    eval(parse(text = .server_context))
499:      parse(text = code)

so it could be worth sanity-checking those usages as well.

See also: rstudio/rstudio#8954


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Activity

  1. added
    bug
    on Feb 11, 2021
  2. cderv commented on Feb 11, 2021

    @cderv
    Collaborator

    Thanks for the investigation @kevinushey !

    We should clearly deal with with some checks in the different place.

    I believe we should also fail earlier with render_site if no front matter is correctly parsed. The tools works only if the document starts with a YAML front matter.

  3. added
    next
    on May 18, 2021
  4. yihui commented on May 18, 2021

    @yihui
    Collaborator

    Fixed now. Thanks for the report!

  5. added 3 commits that reference this issue on Jun 18, 2021
    118f164
    1e64a76
    c3e1636
  6. github-actions commented on Nov 16, 2021

    @github-actions

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

  7. locked as resolved and limited conversation to collaborators on Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions