Skip to content

custom cli format output could not evaluate {} expression #519

@mcol

Description

@mcol

This function fails, despite all possible places and ways i is defined:

test <- function(i = 6) {
  i <- 7
  map <- NULL
  for (i in 1:5) {
    map[[i]] <- mirai::mirai({ Sys.sleep(i); i },
                             .args = list(i = 8),
                             i = 9)
  }
  cli.opts <- list(type = "task",
                   format = "{cli::pb_spin} Input: {.strong {i}}")
  mirai::collect_mirai(map, options = list(.progress = cli.opts))
}

test()
# Error in `"id" %in% names(args)`:
# ! Could not evaluate cli `{}` expression: `i`.
# Caused by error in `eval(expr, envir = envir)`:
# ! object 'i' not found
# Type .Last.error to see the more details.

The only way I've found to make it work, is to set i in the global namespace. Is there a way to support custom formats such as the one above in .progress?

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