Skip to content

last_trace() advice not helpful when missing {crayon} [aka odd mix of {crayon} & {cli}] #1806

@MichaelChirico

Description

@MichaelChirico

I got an error and saw the expected advice:

Error in `FUN()`:
! `arg` must be a symbol
Run `rlang::last_trace()` to see where the error occurred.

However, the current environment doesn't have {crayon}, so that advice turned out to be less than helpful:

rlang::last_trace()
# Error in loadNamespace(x) : there is no package called ‘crayon’

I peeked around and AFAICT ultimately this is the issue:

rlang/R/utils.R

Lines 165 to 166 in 7371bac

if (cli::num_ansi_colors() >= 256) {
crayon::make_style(grDevices::grey(0.6), colors = 256)(x)

I see three options:

  1. Use {cli} completely and avoid {crayon}
  2. Don't give the unhelpful advice if {crayon} is missing
  3. Add a check_installed("crayon") branch in style_dim_soft().

This last is very easy and I'll file a quick PR, but I wonder if the others will be worth the higher investment.

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