Closed MichaelChirico closed 10 months ago
Imports
means a heavier dependency, and codetools is required only conditionally, so I prefer not making it a hard dependency. For Windows and macOS users, it's very unlikely that codetools is not installed, so this problem only matters for Linux users (when r-base
is installed but not r-base-recommended
).
e.g.
if (!requireNamespace("codetools", quietly = TRUE)) stop("'codetools' is required for caching")
I agree that the error message is clearer than
Error in loadNamespace(x) : there is no package called ‘codetools’
but this type of escaping is a tedious task for every package in Suggests
. I could make it a function and call the function, though, if the current error message looks confusing enough for you. Thanks!
Closing for now, I'll revisit the next time I see the error. My memory is it came out in a confusing context, but I'll double-check before deciding the right fix.
Thanks! I'm open to enhancing the error message in future.
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.
{codetools} is used twice for caching in {knitr}:
https://github.com/yihui/knitr/blob/ec4c9b632e1b35994340848884a31da2ca24640a/R/cache.R#L110-L113
https://github.com/yihui/knitr/blob/ec4c9b632e1b35994340848884a31da2ca24640a/R/block.R#L329-L330
In neither place is proper escaping done for treating it as a suggests (e.g.
if (!requireNamespace("codetools", quietly = TRUE)) stop("'codetools' is required for caching")
), so I would move the package to Imports.If this is unintentional / a workaround is warranted, then we could either drop {codetools} or give proper escapes for its usage.