How to get rid of warning messages after installing R?
Put the following to your $HOME/.bashrc
export LANG=en_US.UTF-8
It seems, that for some reason, the $HOME/.profile is not sourced in starting the terminal.
Problem: Locale variables indicating what encoding to use are not set. To see the issue, in Terminal, type locale
, and you likely get something like
LANG=
LC_COLLATE=
LC_CTYPE=
LC_MESSAGES=
LC_MONETARY=
LC_NUMERIC="en_US.UTF-8"
LC_TIME=
LC_ALL=
LC_NUMERIC
may or may not be set, but given your errors, the rest are either not set or set to something R can't use. If those variables are empty, R is going to complain. To fix the problem:
Option 1: Terminal Preferences Go to Terminal's Preferences. Under the "Advanced" tab, make sure "Text Encoding" is set to "Unicode (UTF-8)" (or whatever you need). Make sure the checkbox underneath for "Set locale environment variables on startup" is checked. Unchecking it tends to leave locale variables unset or as "C", unless you've changed .bash_profile, .bashrc, or .profile (depending on your system). That may be enough to fix your problem. If not:
Option 2: Set from R To set them from inside of R, type
R> Sys.setenv(LANG="en_US.UTF-8")
R> Sys.setenv(LC_ALL="en_US.UTF-8")
...which should set all of the variables R is complaining about.
Option 3: Set from Terminal To set them from Terminal, type
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
...which should set the rest of the variables R is complaining about.
Check: In Terminal, type locale
again. You should get
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
Restart R, and you should be set.
For R this is what worked from the terminal
$ defaults write org.R-project.R force.LANG en_US.UTF-8
See Installing R on Mac - Warning messages: Setting LC_CTYPE failed, using "C"