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

find_external_resources errs with variable chunk eval #1247

Closed
aronatkins opened this issue Jan 17, 2018 · 5 comments
Closed

find_external_resources errs with variable chunk eval #1247

aronatkins opened this issue Jan 17, 2018 · 5 comments
Milestone

Comments

@aronatkins
Copy link
Contributor

This test document was trimmed from a much larger one. It shows that a variable used to allow / prohibit the evaluation of a chunk produces an error (which appears to be ignored).

---
output: html_document
---

```{r setup,echo=FALSE}
hasNotes <- FALSE
```

Here is some text in a document.

```{r echo = FALSE, results = 'asis', eval = hasNotes}
cat("**We have notes!**\n")
```

Run the following in the R console:

rmarkdown::find_external_resources("error.Rmd")

Here's the output:

Error in eval(x, envir = envir) : object 'hasNotes' not found
[1] path     explicit web     
<0 rows> (or 0-length row.names)

The find_external_resources function is used by rsconnect to discover files referenced by an Rmd that need to be included in a deployment bundle:
https://github.com/rstudio/rsconnect/blob/def0d46c806588af4b3c45853489eb997c97158d/R/deployDoc.R#L54

We don't really want to execute the document when analyzing it for resources. I was surprised to see this error about hasNotes. The find_external_resources function is supposed to be making "best effort" to identify resources.

I do not know if this error is preventing resource discovery; it appears to be working fine. The error in my deploy console made me question it.

@yihui
Copy link
Member

yihui commented Jan 17, 2018

Duplicate of #1154

@yihui yihui marked this as a duplicate of #1154 Jan 17, 2018
@yihui yihui added this to the v1.9 milestone Jan 17, 2018
@aronatkins
Copy link
Contributor Author

@yihui Is there a way to suppress that purl error? It's ugly when appearing in an rsconnect deploy stream and gives the impression that things aren't quite right. Maybe rsconnect just needs to silence it somehow?

Preparing to deploy document...DONE
Uploading bundle for document: 3...Error in eval(x, envir = envir) : object 'hasNotes' not found
DONE
Deploying bundle: 8 for document: 3 ...

@yihui
Copy link
Member

yihui commented Jan 17, 2018

I guess it will require a change in knitr. I'll see how difficult it is.

@yihui yihui mentioned this issue Jan 25, 2018
3 tasks
@yihui yihui closed this as completed in 90475fe Jan 25, 2018
@yihui
Copy link
Member

yihui commented Jan 25, 2018

Should be fixed now. Thanks for the report!

@github-actions
Copy link

github-actions bot commented Nov 3, 2020

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants