5

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.

2 Answers 2

5

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.

0

NB. There is one more thing that you need to consider after changin "default locale" setting in terminal. Check your code and remove all lines in R that do force to change locale setting while running the code, i.e. delete "Sys.setenv(LANG = "en")" if you use it somewhere in the code. You can check that you have correct settings by running "system("locale")" in R.

2
  • This does not answer the author's question.
    – Ramhound
    Commented Feb 9, 2017 at 15:52
  • Actually id does. I just had the same problem and just changing default locale wasn't helping. Then I realized that in one of dozens modules in my script I had Sys.setenv function which rewrited default settings. Commented Feb 9, 2017 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .