Skip to content

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

@wjschne

Description

@wjschne

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))
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions