Internal error with `ansi_strwrap`when string contains `\r\n\r` in `cli_abort()` message
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
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ả
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của r-lib/cli
-
C function cli_progress_sleep() is used in an example but not documented.Có thể đã có người làm @shreyabyte đã nhận 64 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
`pb_elapsed` should not show minutes & fractions of secondsCó thể đã có người làm @mcol đã nhận 419 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
feat: add `.duration` and `.time_ago` inline stylesCó thể đã có người làm @jjjermiah đã nhận 180 ngày trước. Đang mởfeature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
docs: provide llms.txtĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
AlexsLemonade/scpca-nf#1357 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
REditorSupport/vscode-R#1883 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Error out post processing step if there are multiple folders in /exec with the same index numberĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày