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

quarto:::check_extension_approval(FALSE, "Quarto template") returns NULL instead of TRUE after entering "Y" #212

Closed
wjschne opened this issue Sep 13, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@wjschne
Copy link

wjschne commented Sep 13, 2024

When using quarto::quarto_use_template, to install a quarto extension, the user is prompted to indicate whether the author of the extention is trusted. When the user indicates trust with the letter Y, the function returns:

Error in if (approval) { : argument is of length zero

Upon investigation, it seems that quarto::check_extension_approval returns NULL instead of TRUE after the user responds to the prompt with "Y". Perhaps adding one line to the function like this would fix the problem:

check_extension_approval <- function(no_prompt = FALSE, what = "Something", see_more_at = NULL) {
  if (no_prompt) return(TRUE)

  if (!rlang::is_interactive()) {
    cli::cli_abort(c(
      "{ what } requires explicit approval.",
      ">" = "Set {.arg no_prompt = TRUE} if you agree.",
      if (!is.null(see_more_at)) {
        c(i = "See more at {.url {see_more_at}}")
      }
    ))
  } else {
    cli::cli_inform(c(
      "{what} may execute code when documents are rendered. ",
      "*" = "If you do not trust the author(s) of this {what}, we recommend that you do not install or use this {what}."
    ))
    prompt_value <- tolower(readline(sprintf("Do you trust the authors of this %s (Y/n)? ", what)))
    if (!prompt_value %in% "y") {
      cli::cli_inform("{what} not installed.")
      return(invisible(FALSE))
    } else {
      return(invisible(TRUE))
    }
  }
}
@cderv
Copy link
Collaborator

cderv commented Sep 16, 2024

Oh thank you for finding this !

Really bad issue following latest change. Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants