R locale setting problems on Mac OS X

7,106

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.

Share:
7,106
user260392
Author by

user260392

Updated on September 18, 2022

Comments

  • user260392
    user260392 over 1 year

    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.

  • Ramhound
    Ramhound about 7 years
    This does not answer the author's question.
  • Johnny Cheesecutter
    Johnny Cheesecutter about 7 years
    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.