Include library()
and require()
shims in webr::shim_install()
#371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shim base R
library()
andrequire()
commands so that webR packages are downloaded automatically with an optional menu.It is no longer assumed that an interactive R session will be able to show a
menu()
when offering to download a missing R package. Instead, this now defaults to not showing a menu, withoptions(webr.show_menu = TRUE)
enabling the menu feature globally.This extends the functionality of the global
packageNotFoundError
handler so that the same feature can be used when usingevalR()
. The new shims also ensure thatlibrary()
andrequire()
do not need to be called again once the package is downloaded and available.I have retained the original global handler solution as it provides additional benefits over simply shimming
library()
andrequire()
. For example, when thepackageNotFoundError
handler is active packages can be automatically installed on demand if functions are referred to via namespace, such ascli::cli_alert_success('The cli package works!')
.The webR REPL application now enables both features, including prompting with the confirmation menu, by default.
Fixes #324, #325.