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 is an installation dependency under certain conditions #785

Closed
mdneuzerling opened this issue Aug 14, 2022 · 2 comments · Fixed by #790
Closed

knitr is an installation dependency under certain conditions #785

mdneuzerling opened this issue Aug 14, 2022 · 2 comments · Fixed by #790

Comments

@mdneuzerling
Copy link

mdneuzerling commented Aug 14, 2022

The problem

Under certain conditions, installation of parsnip fails with the following error:

Error installing package 'parsnip':
===================================

* installing *source* package 'parsnip' ...
** package 'parsnip' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'parsnip'
    finding HTML links ... done
    C5.0_train                              html  
    C5_rules                                html  
    add_on_exports                          html  
    add_rowindex                            html  
    augment                                 html  
    autoplot.model_fit                      html  
    bag_mars                                html  
Error: bag_mars.Rd:36: there is no package called 'knitr'
* removing '/opt/R/4.2.1/lib/R/library/.renv/1/parsnip'
Error: install of package 'parsnip' failed [error code 1]
Traceback (most recent calls last):
12: renv::restore()
11: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
10: renv_install_impl(records)
 9: renv_install_staged(records)
 8: renv_install_default(records)
 7: handler(package, renv_install_package(record))
 6: renv_install_package(record)
 5: withCallingHandlers(renv_install_package_impl(record), error = function(e) {
        vwritef("\tFAILED")
        writef(e$output)
    })
 4: renv_install_package_impl(record)
 3: r_cmd_install(package, path)
 2: r_exec_error(package, output, "install", status)
 1: stop(error)
Execution halted
executor failed running [/bin/sh -c Rscript -e "renv::restore()"]: exit code: 1

The error occurs for me when I install earth then parsnip, but I can only reproduce the error on CentOS 7. The error doesn't occur in Debian. If knitr is installed then the error goes away, of course, but I discovered this issue when using vetiver and renv, both of which have no way to automatically pick up on knitr as a dependency.

I believe the actual cause is as follows:

\Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("bag_mars")}
  • parsnip:::make_engine_list("bag_mars") picks up on the "earth" engine, and attempts to call knitr::combine_words.
  • knitr is only a suggested dependency of parsnip. If it's not already installed, R will error here.

Reproducible example

I'm afraid this reprex requires a Dockerfile. I've put up a minimal repository. The renv snapshot is produced by the below line, which is very similar to what vetiver would do:

renv::snapshot(packages = c("earth", "parsnip", "workflows"), prompt = FALSE)

Attempting to build the Docker image will error with the above, although because we're building from source the process may take 20 minutes. The alternative Debian-based Dockerfile doesn't error, and I just can't understand why.

Possible solutions

knitr::combine_words is a very small and self-contained component of knitr. Could this function be copied into parsnip?

I would be happy to contribute a PR, if you think this is a valid issue.

@simonpcouch
Copy link
Contributor

Thank you for reporting this! I'll put in a PR to fix this in a moment. :)

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

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

Successfully merging a pull request may close this issue.

2 participants