Open lorenzwalthert opened 3 years ago
Hello, Yes {styler} is a very good package, I use it regularly. The problem here, reported by some users, was with the R cache folder, where it blocked the ggplot2 code generated to be displayed in the addin and further use of the addin itself. For new users this is very confusing, so I chose to use a minimal formating of the code in the addin and to recommend to use {styler} after that in R scripts.
In a future realease, I want to integrate a feature to display history of code generated (so potentially more code), maybe I'll use {styler} then, it will be more robust than my current solution. And I kinda like Garrick style (https://github.com/gadenbuie/grkstyle), so I've to look closer how all this works.
Victor
Thanks for the explanation. You are not the first to explore this problem unfortunately. A simple workaround to disable the prompt is to use a temporary cache location (instead of one persisting over multiple sessions) by setting an environment variable. It's described here:
https://styler.r-lib.org/reference/caching.html#non-interactive-setup
Bottom line for you:
# temporary set env variable for call to styler.
withr::with_envvar(
R_CACHE_ROOTPATH = file.path(tempdir(), 'R.cache.esquisse'),
styler::style_text(...)
)
Note that this does not add a new dependency to your probject because {withr} is already an indirect dependency (via {shiny} and other packages you import).
Also, maybe once https://github.com/HenrikBengtsson/R.cache/pull/43 is merged and CRAN-released, you could do this:
# temporary set env variable for call to styler.
withr::with_envvar(
R_CACHE_ROOTPATH_ASK = FALSE
styler::style_text(...)
)
If you want to use Garrick over tidyverse style, note that the {R.cache} behavior is the same, because Garrick provides only a style guide (=rules for styling), {styler} provides not just the tidyverse style guide but also the mechanism to format code according to arbitrary style guides.
Happy to assist if you have further questions.
See my https://github.com/HenrikBengtsson/R.cache/pull/43#issuecomment-875185508 comment; per CRAN policies R.cache (>= 0.15.0) no longer have to ask for permission to create it's cache folders as long as they're in a standard location, so there should be no prompt.
Thanks @HenrikBengtsson. I'll add a minimum version requirement for R.cache in https://github.com/r-lib/styler/pull/819. @pvictor this means once this new styler version is released (assuming you want to add {styler} again), just require this minimal version and blocking prompt problem should be resolved.
@pvictor {styler} 1.5.1 is released, where the minimal version requirement for {R.cache} is included, so you could just require styler >= 1.5.1
in your package to get rid of the problems.
@pvictor, as stated above, the problems related to {styler} are now resolved. Would you consider re-adding it?
Thanks for the heads up @lorenzwalthert , I'll look into that
Hi, thanks for this cool package. I saw you removed {styler} in 2f86db9290f463a0b7f0ff986f7c018eef2f68fd.