9

I have the following warning message after upgrading windows 10 whenever I launch Rstudio.

During startup - Warning message: Setting LC_CTYPE= failed

I'm running currently Microsoft R Open version.

Is there a way I could fix this warning message, I found some solutions for Mac at stackoverflow but not for Windows.

moth
  • 1,833
  • 12
  • 29
  • 2
    What does `Sys.getlocale()` return? – alistaire Jan 09 '19 at 05:08
  • 1
    `Sys.getlocale()` returns `"C"` – moth Jan 09 '19 at 06:14
  • 1
    I believe that's the default when it's not set. I'm not sure what the best way to set it in Windows is, but I'm pretty sure setting `LC_ALL` to something like `en_US.UTF-8` like Unix-alikes do won't work; you'll need to figure out what locales are available. Also note that `Sys.setlocale` will only set it for the R session, so you'll need to set it more globally in your OS somewhere. – alistaire Jan 10 '19 at 01:23
  • I cross posted this under RStudio Community and will update here in case of a solution over there -> https://community.rstudio.com/t/during-startup-warning-message-setting-lc-ctype-failed-on-windows/21451 – Taz Jan 12 '19 at 12:55

1 Answers1

4

The best workaround I found for that issue is to set up a .Renviron file and overwrite the locales there.

How to set and modify the .Renviron file is described i.e. in the regarding chaper of the open book Efficient R Programming. Therefore, one needs just to copy the lines

user_renviron = path.expand(file.path("~", ".Renviron"))
file.edit(user_renviron) # open with another text editor if this fails

and afterwards edit the .Renviron file to change the locale. Note that regarding on the OS some locales won't exist and it might be non trivial to install them. However, the locale "C" should always exist. For me also "English_United States.1252" worked on Windows and I added the following lines (including a linebreak) to the .Renviron file

LC_COLLATE  = "English_United States.1252"
LC_CTYPE    = "English_United States.1252"
LC_MONETARY = "English_United States.1252"
LC_NUMERIC  = "English_United States.1252"
LC_TIME     = "English_United States.1252"

Taz
  • 546
  • 5
  • 9
  • This did not fix the issue for me. Nor did changing the .Rprofile as suggested here: https://community.rstudio.com/t/during-startup-warning-message-setting-lc-ctype-failed-on-windows/21451 – Jayden.Cameron Jan 25 '22 at 19:39