Macos – R locale setting problems on Mac OS X

localemacosr

I'm trying to install packages in R using Mac OS X, but I keep getting tar: Failed to set default locale errors for any package I try. After Googling around I found that this was due to unexpected locale settings. I set them back to en_US.UTF-8 as recommended elsewhere, but still can't install packages. When I run locale in Terminal, I 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"

But when I run system("locale") in R I get:

LANG="en_US.UTF-8"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

I do remember setting some locale settings to "C" awhile ago, for some other purpose, but forget where now.

Best Answer

This command seems to fix it:

defaults write org.R-project.R force.LANG en_US.UTF-8

After restarting R, no more warnings about the default locale.

Related Question