Deploying in Connect: Error in eval(x, envir = envir)

I have two Rmd files. File 1 the master:

>   ---
>    title: "Test"
>    output: html_document
>    ---
> 
>    ```{r, echo = FALSE, include=TRUE}
>    child_docs <- "header.Rmd"
>    ```
>    ```{r, run_child, child = child_docs}
>    ```

File 2: header.Rmd

# Report 1
Chunk number 1

I can knit the documents without error. I can also deploy the document to Connect, but I get the error:

Preparing to deploy document...DONE
Uploading bundle for document: 18...[WARNING] This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata,
  e.g. by using --metadata pagetitle="..." on the command line.
  Falling back to 'header.utf8'
Error in eval(x, envir = envir) : object 'child_docs' not found
DONE
Deploying bundle: 42 for document: 18 ...

Although it states that child_docs isn't found, it still deploys. Any ideas?


Update: Issue raised at https://github.com/rstudio/rsconnect/issues/429

Thanks for sharing this! This is an interesting one!

I am able to reproduce this issue, so you're definitely not alone! :smile: I believe this has something to do with the way that package dependencies are introspected. I suspect that is where the eval(x, envir = envir) is coming from.

I'm not savvy enough to know where exactly it is coming from, but I suspect from somewhere in the rsconnect package or perhaps packrat's dependency introspection. It could also be something about the order of variable definition / reference in code chunks and more fitting for knitr discussion :man_shrugging:

I'm definitely glad that the error isn't fatal though! If you want to keep tracing the issue, it might be a good fit for an issue on the rsconnect repository - the reprex is a huge help!