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

knitr creates a copy of evaluate::evaluate as the default evaluate hook value #1441

Closed
aronatkins opened this issue Oct 4, 2017 · 3 comments
Milestone

Comments

@aronatkins
Copy link
Contributor

aronatkins commented Oct 4, 2017

The default evaluate hook is defined as:

knitr/R/hooks.R

Lines 9 to 14 in 0d648a6

.default.hooks = list(
source = .out.hook, output = .out.hook, warning = .out.hook,
message = .out.hook, error = .out.hook, plot = .plot.hook,
inline = .inline.hook, chunk = .out.hook, text = identity,
evaluate = evaluate::evaluate, document = identity
)

This means that the default hook is tied to whatever version of evaluate was available at the time knitr was installed. If the version of evaluate changes, the knitr hook is not changed to reflect the new definition of evaluate::evaluate.

This explains errors like:

Quitting from lines 9-10 (helloworld1.Rmd)
Error in evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,  :
  unused argument (include_timing = include_timing)
Calls: <Anonymous> ... call_block -> block_exec -> in_dir -> evaluate -> evaluate_call

Reported here:
https://stackoverflow.com/questions/40198189/r-markdown-error-in-evaluate-call-when-knitting-any-rmd-file

We have also seen this problem when trying to use knitr inside a packrat cache. In the packrat scenario, we may be using the same version of knitr with multiple versions of evaluate (depending on a particular piece of content).

You probably can avoid this issue with something like:

.default.hooks = list(
  # ...
  evaluate = function(...) evaluate::evaluate(...)
  # ...
)
@aronatkins
Copy link
Contributor Author

aronatkins commented Oct 4, 2017

Workaround is to re-register the evaluate hook based on the version of evaluate::evaluate available:

knitr::knit_hooks$set(evaluate = evaluate::evaluate)

@yihui yihui added this to the v0.18 milestone Oct 4, 2017
@yihui yihui closed this as completed in d6b53e0 Oct 4, 2017
@yihui
Copy link
Owner

yihui commented Oct 4, 2017

Sounds like a reasonable fix. Done. Thanks @aronatkins!

@github-actions
Copy link

github-actions bot commented Nov 10, 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 10, 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