Visitar URL original
knitr creates a copy of evaluate::evaluate as the default evaluate hook value · Issue #1441 · yihui/knitr · GitHub
Skip to content

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

Closed

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

Activity

  1. aronatkins commented on Oct 4, 2017

    @aronatkins
    ContributorAuthor

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

    knitr::knit_hooks$set(evaluate = evaluate::evaluate)
  2. added this to the milestone on Oct 4, 2017
  3. yihui commented on Oct 4, 2017

    @yihui
    Owner

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

  4. github-actions commented on Nov 10, 2020

    @github-actions
    Contributor

    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.

  5. locked as resolved and limited conversation to collaborators on Nov 10, 2020
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions