Skip to content

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

Description

@aronatkins

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(...)
  # ...
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions