RStudio crashes when running Sys.getlocale("LC_MESSAGES") but RGui and Rscript work fine

I recently installed R 4.2.0 and RStudio 2022.02.2 Build 485 on Windows.

Every time I run the RJDBC::JDBC function in RStudio, the R session aborts with "R encountered a fatal error. The session was terminated". In RGui, the function runs fine.

I debugged the JDBC function and have isolated the problem to Sys.getlocale("LC_MESSAGES"). Without fail, in RStudio, when I run Sys.getlocale("LC_MESSAGES"), the R session aborts.

I have tried:

  • Installing older versions of RStudio (same error with the last four releases)
  • Verified that RStudio and RGui are using the same R executable, using R.home()
  • Restarting the machine
  • Checking that Sys.getenv() returns (almost) the same results, as suggested in this stackoverflow answer for a similar question

How do I fix this?

What happens when you run Sys.getlocale() i.e. without any params ?

The documentation at ?locale says LC_MESSAGES is invalid for windows, however i can query it without crashing R, i just get an empty string returned.
It makes me wonder about the database driver you have, if its is OS independent or might perhaps be good for unix only where LC_MESSAGES might be relevant ?

P.s. i dont work with databases in R myself hardly ever so im probably not the best person to help you.

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

Same result in both RStudio and RGui

I think this related to this issue with R 4.2

You can try with the patched version of R 4.2

1 Like

Thank you! That did it. Next time I know to search github directly instead of just googling.

This topic was automatically closed 7 days after the last reply. 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.