Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Internal error with `ansi_strwrap`when string contains `\r\n\r` in `cli_abort()` message

Đã đóng
#667 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
cli

Hướng nghiên cứu

Start by reproducing the minimal cli::cli_abort() example in an R console and tracing cli::ansi_strwrap(), which is identified in the backtrace as the failing entry point. Compare it with the longer knitr/txtProgressBar stderr example; done means messages containing these carriage-return and newline sequences no longer produce an internal error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug tidy-dev-day :nerd_face:

Running in RStudio R console this leads to an internal error

> cli::cli_abort("processing file: report.qmd\r\n\r  |")
Error:
! ! Internal error in `cli::ansi_strwrap()`
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error:
! ! Internal error in `cli::ansi_strwrap()`
---
Backtrace:
     ▆
  1. └─cli::cli_abort("processing file: report.qmd\r\n\r  |")
  2.   └─rlang::abort(...)
  3.     └─rlang:::signal_abort(cnd, .file)
  4.       └─rlang::cnd_message(cnd, inherit = TRUE, prefix = TRUE)
  5.         └─rlang:::cnd_message_format_prefixed(cnd, ..., parent = FALSE)
  6.           └─rlang:::cnd_message_format(cnd, ..., alert = alert)
  7.             └─rlang (local) cli_format(glue_escape(lines))
  8.               └─rlang:::.rlang_cli_format(x, cli::format_error)
  9.                 └─cli::cli_format(x, .envir = emptyenv())
 10.                   └─cli::cli_fmt(...)
 11.                     └─cli:::cli__fmt(rec, collapse, strip_newline)
 12.                       ├─base::do.call(app[[msg$type]], msg$args)
 13.                       └─cli (local) `<fn>`(text = `<named list>`, id = "cli-8944-50", class = NULL)
 14.                         └─cli:::clii_bullets(app, text, id, class)
 15.                           └─base::lapply(...)
 16.                             └─cli (local) FUN(X[[i]], ...)
 17.                               └─app$text(text[[i]])
 18.                                 └─cli:::clii_text(app, text)
 19.                                   └─app$xtext(text)
 20.                                     └─cli:::clii__xtext(...)
 21.                                       └─cli::ansi_strwrap(text, exdent = exdent, width = app$get_width(extra = padding))
 22.                                         └─throw(cli_error("Internal error in {.fun cli::ansi_strwrap}"))

The message string is part of the content created by knitr progress bar which uses txtProgressBar.

I encountered this in the context of quarto R package, where quarto render is run with processx::run() and I wanted to use cli_abort() in the error catch
https://github.com/quarto-dev/quarto-r/blob/8a0bcb3a7cf35ce4eb2b412d6d09542cc7b2b35d/R/quarto.R#L41-L48

The full stderr I get in the code above is the following, which leads to same error

msg <- "processing file: report.qmd\r\n\r  |                                                          \r  |                                                    |   0%\r  |                                                          \r  |.................                                   |  33%                  \r  |                                                          \r  |...................................                 |  67% [unnamed-chunk-1]\r\n\n\nQuitting from lines 8-9 [unnamed-chunk-1] (report.qmd)\r\nError:\r\n! true message\r\n\r                                                                                                            \r\nExécution arrêtée\r\n"
> cli::cli_abort(msg)
Error:
! ! Internal error in `cli::ansi_strwrap()`
Run `rlang::last_trace()` to see where the error occurred.
Ngôn ngữ chính
R
Star
729
Fork
94
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-lib/cli

Tất cả issue của r-lib/cli

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.