GitHub Action with ubuntu-20.04: Locale (LC_CTYPE) is C.UTF-8 / localeToCharset() returns NA

I want to report an issue that I faced when migrating from Travis CI to GitHub Actions. To get started with GitHub Actions, I used usethis::use_github_action_check_standard(). R-CMD-check.yaml tells me that I should report issues here.

The polmineR package I develop and maintain is a package for text analysis, so encodings matter. To iconv data to the session charset, I frequently use localeToCharset(). Yet on GitHub Action ubuntu-20.04, localeToCharset() yields NA values, which caused package tests to fail. Note that this does not occur in Windows and macOS test environments.

The solution I found for my package is to introduce a call to Sys.setlocale("LC_CTYPE", "en_US.UTF-8") in the workflow before rcmdcheck::rcmdcheck(). Then the package can be built including the vignette, but package tests would still fail. So I enforced (re-)setting the locale in zzz.R to US.UTF-8 if localeToCharset() returns NA. This is not yet a CRAN-compatible solution at this stage.

I do not yet fully understand what's wrong! By including a Sys.getlocale() call before rcmdcheck::rcmdcheck(), I learn that the locale is C.UTF-8. But localeToCharset() should be able to process this. However, Sys.setlocale("LC_CTYPE", "C.UTF-8") is not possible. But I do not guess that this is really the problem?

Even though I have found a workaround, I want to report that the default "R CMD check" workflow will not work out of the box because the locale is set in a way that may raise problems within R. If including Sys.setlocale("LC_CTYPE", "C.UTF-8") is not yet enough, what would do the job? This is what I do not know.

And note that this is a Linux issue, things work out of the box in the Windows and macOS test environments!

Anyway, thanks for your great work that is tremendously helpful for using GitHub Actions.

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.