Skip to content

Package cli use of "Suggests" rather than "Imports" seems odd #810

Description

@bnaras

Clearly rlang functions are being used:

cli/R/rlang.R

Line 46 in 3dd94c0

rlang::abort(

I encountered this when my package which just began importing cli failed CRAN checks.

Activity

  1. msberends commented on Apr 2, 2026

    @msberends

    Yea, had this too, but I would only add rlang to Imports, not any of the others packages to keep the dependencies as few as possible. A solution for the other pkgs is to call rlang::check_is_installed() in cli functions you’re using other deps in.

  2. gaborcsardi commented on Apr 2, 2026

    @gaborcsardi
    Member

    What exactly is the issue?

  3. msberends commented on Apr 2, 2026

    @msberends

    If you rely on cli, eg:

    #’ @importFrom cli cli_abort
    my_abort <- function() {
      cli_abort(“Something”)
    }

    Then add cli to Imports as devs should, then:

    1. The package will only install cli, not rlang
    2. yet rlang is required for cli_abort
    3. The function my_abort will fail since rlang is not installed

    So it only works if rlang was installed because users also installed tidyverse for example. I’m afraid this is a design flaw in the dependency tree.

  4. gaborcsardi commented on Apr 2, 2026

    @gaborcsardi
    Member

    Right. rlang is an optional dependency of cli, and it is only needed for some features, namely cli_abort() and co. Other packaging systems, e.g. Rust crates, have ways to express this, but unfortunately the R package system does not.

    I cannot currently add rlang as a hard dependency because pak uses cli, but pak does not work with rlang. I can try to document better that you'll also need to import rlang if you use cli_abort().

    Do you see any other way to improve the situation? Maybe cli_abort() could check that the called package depends on rlang, but that could be overkill and/or fragile.

  5. msberends commented on Apr 3, 2026

    @msberends

    I see.

    Then documenting + checking within cli_inform (and friends) would be best I think. Checks deps of others packages is definitely overkill.

    You could add a simple:

    if (!"rlang" %in% rownames(utils::installed.packages())) {
      stop("This requires the rlang package. Install it using install.packages()")
    }

    Or something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions