Skip to content

Leiningen engine fails to knit without additional plugin #1176

@phillc73

Description

@phillc73

engine.R indicates that Clojure is supported through the Leiningen REPL

else paste(switch(
    engine, bash = '-c', coffee = '-e', groovy = '-e', lein = 'exec -e',
    mysql = '-e', node = '-e', perl = '-e', psql = '-c', python = '-c',
    ruby = '-e', scala = '-e', sh = '-c', zsh = '-c', NULL
  ), shQuote(paste(options$code, collapse = '\n')))

There is also a pull request in the knitr-examples repository with a Clojure example.

Unfortunately, knitting the example fails.

Error generated is:

processing file: test.Rmd
  |.......                                                          |  11%
  ordinary text without R code

  |..............                                                   |  22%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |......................                                           |  33%
  ordinary text without R code

  |.............................                                    |  44%
label: unnamed-chunk-1 (with options) 
List of 1
 $ engine: chr "lein"

running: lein  exec -e '(def x "Hello world!")
(println x)'

Quitting from lines 11-13 (test.Rmd) 
Error in engine(options) : 'exec' is not a task. See 'lein help'.

Did you mean this?
         new
         check
Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> engine
In addition: Warning message:
running command ''lein'  exec -e '(def x "Hello world!")
(println x)' 2>&1' had status 1 
Execution halted

Leiningen is in basic default configuration and the version information is:

Leiningen 2.6.1 on Java 1.8.0_72-internal OpenJDK 64-Bit Server VM

To fix this problem, the lein-exec plugin must be added to the leiningen ~/.lein/profiles.clj file:

{:user {:plugins [[lein-exec "0.3.6"]]}}

Once this is added, the example code chunk renders.

I didn't find this information anywhere else in knitr documentation, and I'm not sure where it should or could be added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docNeed to improve documentation

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions