Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call arg ignored for .internal = TRUE in cli_abort() #1386

Closed
salim-b opened this issue Mar 31, 2022 · 2 comments · Fixed by r-lib/cli#479
Closed

call arg ignored for .internal = TRUE in cli_abort() #1386

salim-b opened this issue Mar 31, 2022 · 2 comments · Fixed by r-lib/cli#479

Comments

@salim-b
Copy link
Contributor

salim-b commented Mar 31, 2022

cli::cli_abort(.internal = TRUE) internal error messages always assume the error would be in the cli package, regardless of call. rlang::abort(.internal = TRUE) doesn't have this problem.

good <- function() rlang::abort("oops", call = rlang::caller_env(), .internal = TRUE)
bad <- function() cli::cli_abort("oops", call = rlang::caller_env(), .internal = TRUE)

good()
#> Error:
#> ! oops
#> ℹ This is an internal error, please report it to the package authors.
bad()
#> Error:
#> ! oops
#> ℹ This is an internal error in the cli package, please report it to the package
#>   authors.

Created on 2022-03-31 by the reprex package (v2.0.1)

I think the underlying issue is in rlang::abort():

rlang/R/cnd-abort.R

Lines 300 to 307 in 9d8e74f

message_info <- cnd_message_info(
message,
body,
footer,
caller,
use_cli_format = use_cli_format,
internal = .internal
)
uses cnd_message_info(call = caller) but instead should be cnd_message_info(call = call) because caller <- caller_env().

@gaborcsardi
Copy link
Member

@lionel- Can you help me out here please? Thanks!

@lionel-
Copy link
Member

lionel- commented Mar 31, 2022

I'll just transfer the issue in rlang since I won't look into a fix in the short term. The frame handling in abort() is already very complicated so this will take some thought.

@lionel- lionel- transferred this issue from r-lib/cli Mar 31, 2022
lionel- added a commit to r-lib/cli that referenced this issue Jun 8, 2022
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 17, 2022
# cli 3.4.1

* cli has better error messages now.

* New `format_inline()` argument: `collapse`, to collapse multi-line output,
  potentially because of `\f` characters.

# cli 3.4.0

* New experimental styles to create ANSI hyperlinks in RStudio and
  terminals that support them. See `?cli::links` for details (#513).

* Expressions that start and end with a `{}` substitution are now styled
  correctly. E.g. `{.code {var1} + {var2}}` (#517).

* New `{.obj_type_friendly}` inline style to format the type of an R object
  in a user friendly way (#463).

* Improved vector collapsing behavior. cli now shows both the beginning
  and end of the collapsed vector, by default (#419).

* Nested `cli()` calls work now (#497).

* Return values now work as they should within `cli()` calls (#496).

* Style attributes with underscores have new names with dashes instead:
  `vec_sep`, `vec_last`, `vec_trunc`, `string-quote`. The old names still
  work, but the new ones take precedence (#483).

* cli now does not crash at the end of the R session on Arm Windows
  (#494; @kevinushey)

* Vectors are truncated at 20 elements now by default, instead of 100 (#430).

* 20 new spinners from the awesome
  [cli-spinners](https://github.com/sindresorhus/cli-spinners) package,
  and from @HenrikBengtsson in #469.
  Run this to demo them, some need UTF-8 and emoji support:

  ```r
  new <- c("dots13", "dots8Bit", "sand", "material", "weather", "christmas",
    "grenade", "point", "layer", "betaWave", "fingerDance", "fistBump",
    "soccerHeader", "mindblown", "speaker", "orangePulse", "bluePulse",
    "orangeBluePulse", "timeTravel", "aesthetic", "growVeriticalDotsLR",
    "growVeriticalDotsRL", "growVeriticalDotsLL", "growVeriticalDotsRR")
  demo_spinners(new)
  ```

* cli exit handlers are now compatible again with the withr package (#437).

* cli functions now keep trailing `\f` characters as newlines.
  They also keep multiple consecutive `\f` as multiple newlinees (#491).

* `{}` substitutions within inline styles are now formatted correctly.
  E.g. `{.code download({url})}` will not add backticks to `url`, and
  `{.val pre-{x}-post}` will format the whole value instead of `x`.
  (#422, #474).

* cli now replaces newline characters within `{.class ... }` inline styles
  with spaces. If the `cli.warn_inline_newlines` option is set to TRUE, then
  it also throws a warning. (#417).

* `code_highlight` now falls back to the default theme (instead of no theme)
  for unknown RStudio themes (#482, @rossellhayes).

* `cli_abort()` now supplies `.frame` to `abort()`. This fixes an
  issue with the `.internal = TRUE` argument (r-lib/rlang#1386).

* cli now does a better job at detecting the RStudio build pane, job pane
  and render pane, and their capabilities w.r.t. ANSI colors and hyperlinks.
  Note that this requires a daily build of RStudio (#465).

* New functions for ANSI strings: `ansi_grep()`, `ansi_grepl()`,
  `ansi_nzchar()`. They work like the corresponding base R functions, but
  handle ANSI markup.

* `style_hyperlink()` (really) no longer breaks if the env variable `VTE_VERSION`
  is of the form `\d{4}`, i.e., 4 consecutive numbers (#441, @MichaelChirico)

* `cli_dl()` and its corresponding `cli_li()` can now style the labels.

* The behavior cli's inline styling expressions is now more predictable.
  cli does not try to evaluate a styled string as an R expression any more.
  E.g. the meaning of `"{.emph +1}"` is now always the "+1", with style
  `.emph`, even if an `.emph` variable is available and the `.emph + 1`
  expression can be evaluated.

* Functions that apply bright background colors (e.g. `bg_br_yellow()`) now
  close themselves. They no longer format text after the end of the function
  (#484, @rossellhayes).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants