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

code_theme_default() errors when in RStudio, but without {rstudioapi} #697

Closed
dgkf-roche opened this issue Jun 18, 2024 · 0 comments
Closed

Comments

@dgkf-roche
Copy link

code_theme_default() uses is_rstudio() (by way of rstudio_detect) to determine whether to theme the output for RStudio. This correctly discovers that one is in RStudio, but then assumes that one must have rstudioapi available to load.

This is often not the case. Especially when a project uses renv - only packages relevant to the project will be included in the local library. This results in an error when trying to display .Last.error

# Error:                                                                                       
# ! error in pak subprocess
# Caused by error in `verify_extracted_package(filename, pkg_cache)`:
# ! /tmp/RtmpLAlqvr/file158119387aa7/src/contrib/x86_64-pc-linux-gnu-ubuntu-20.04/4.2/fastglm_0.0.3.tar.gz is not a valid binary, it is missing fastglm/Meta/package.rds.
# Type .Last.error to see the more details.
> .Last.error
# Error in loadNamespace(x) : there is no package called ‘rstudioapi’

Perhaps this condition should also check whether requireNamespace("rstudioapi", quietly = TRUE)

cli/R/prettycode.R

Lines 239 to 244 in 71fd2a5

rs <- rstudio_detect()
if (rs$type %in% c("rstudio_console", "rstudio_console_starting")) {
opt <- code_theme_opt("cli.code_theme_rstudio")
if (!is.null(opt)) return(opt)
code_theme_default_rstudio()
} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant