Skip to content

Can check_installed() be used inside tryCatch()? #1402

@yutannihilation

Description

@yutannihilation

I hoped the following code ignores all errors yet asks users to install noSuchPackage if it's not installed. Are there anyway to make this work? I guess the answer is probably no because check_installed() somehow uses the mechanism of tryCatch() behind the scene, but want to confirm (I read the code, but I couldn't understand what's happening).

tryCatch(
  rlang::check_installed("noSuchPackage"),
  error = \(e) invisible(NULL)
)

The context is we see this problem in ggplot2:

tidyverse/ggplot2#4845

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorsession:state

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions