Skip to content

R CMD CHECK ERROR on r-devel-linux-x86_64-debian-clang #497

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

Closed
lorenzwalthert opened this issue Apr 25, 2019 · 9 comments · Fixed by #499
Closed

R CMD CHECK ERROR on r-devel-linux-x86_64-debian-clang #497

lorenzwalthert opened this issue Apr 25, 2019 · 9 comments · Fixed by #499

Comments

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Apr 25, 2019

Most likely due to the charset changed from UTF-8 to ISO8859-15 and special characters printed with the cli packge, which does not fail on the aforementioned flavor.
Seems to appear in other repos also, e.g. pillar and was discussed on r-devel, but I don't know which conclusions to draw from it. One potential fix is to skip tests on CRAN if the encoding is not UTF8, but this seems not an ideal solution. It was done here for example.

This is how the output of styler looks in case things are going well:
Screen Shot 2019-04-25 at 22 57 39

I don't know how to fix this. We are required to submit a new version of styler to CRAN for other reasons, namely #490, until May 10, so I thought we could fix this as well until then (if we knew how).

cc: @krlmlr, @gaborcsardi, @davidgohel.

@gaborcsardi
Copy link
Member

cli does not output the UTF-8 characters if the locale is not UTF-8. So one fix is to call cli::is_utf8_output() and if FALSE, then you need to use the ASCII output in the expectation.

@lorenzwalthert
Copy link
Collaborator Author

lorenzwalthert commented Apr 25, 2019

Thanks for the prompt answer :-) I am not sure I fully understand. My use case is

cli::cat_bullet(bullet = "info")

So do think the best ways to handle this situation is to replace this code with something like this?

if (cli::is_utf8_output()) {
  cli::cat_bullet(bullet = "info")
} else {
  cat("[info]") # or any other ASCII character that looks similar to the info bullet?
}

We could put that functionality in a wrapper for easy re-use within styler.

@gaborcsardi
Copy link
Member

No, you only need to change the tests. cli automatically changes the output if there is no UTF-8 support. You just need to change the test strings you compare against.

@gaborcsardi
Copy link
Member

cli::symbol$bullet
[1] ""withr::with_options(list(cli.unicode = FALSE), cli::symbol$bullet)
[1] "*"

@lorenzwalthert
Copy link
Collaborator Author

Ok, now with the example I think I get it: I just make sure the reference value in the test is depending on whether or not UTF-8 is available, right?

@gaborcsardi
Copy link
Member

Right.

@lorenzwalthert
Copy link
Collaborator Author

I appreciate your help Gabor. Thanks.

@gaborcsardi
Copy link
Member

NP. Note that you can test this on R-hub before you submit.

rhub::platforms()
debian-clang-devel:
  Debian Linux, R-devel, clang, ISO-8859-15 locale.
...

@lorenzwalthert
Copy link
Collaborator Author

Yes I saw that on twitter. Will definitively make use of it 👍 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants