46

I'm trying to install a package into R, something I swore on my blood never to do, yet here I am.

The command supposedly goes:

install.packages('NCStats',,'http://www.rforge.net/')` 

while I am enjoying the healthy dose of:

Warning: dependencies 'nortest', 'plotrix', 'sciplot', 'car', 'gplots', 'gdata', 'Hmisc', 'TeachingDemos' are not available  
trying URL 'http://www.rforge.net/bin/macosx/leopard/contrib/2.11/NCStats_0.1-4.tgz'  
Content type 'application/x-gzip' length 237120 bytes (231 Kb)  
opened URL  
=================================================="  
downloaded 231 Kb  
tar: Failed to set default locale  
The downloaded packages are in
    /var/folders/Qj/Qjps7xnxFcWdSHsJY3lo+k+++TI/-Tmp-//RtmpzNO8MM/downloaded_packages`

Le-sigh. Anybody know how I can tell tar what locale I'm in, not that I understand why it needs that or why it can't just know it already?

I'm running OSX 10.6.4 and R 2.11.1 GUI 1.34 Leopard build 64-bit (5589).

5
  • 2
    For starters, how about trying to satisfy the noted Depends you do not seem to have on your box? Oct 11, 2010 at 15:57
  • 1
    what do you get returned from Sys.getlocale() ?
    – Joris Meys
    Oct 11, 2010 at 16:51
  • Ack, too bad Joris, I forgot to check that before I tried the answer below, but I suspect it was Icelandic or something, since that's what my system preferences are. Dirk, since this package doesn't work after that command, it's unusable, I'm not going to navigate some labyrinth of dependancies.
    – gakera
    Oct 11, 2010 at 20:33
  • Why would you swear you never would install a package?
    – jzadra
    Jun 4, 2020 at 22:46
  • 10 years ago it was a pain (as you can see). Now it's much nicer, and my blood has boiled off.
    – gakera
    Dec 14, 2021 at 15:48

4 Answers 4

83

Step 1 (In R Console)

system('defaults write org.R-project.R force.LANG en_US.UTF-8')

Step 2: Restart R

Source: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Internationalization-of-the-R_002eapp

4
  • 12
    Thank you, that works. To be 100% clear, that command is copy pasted into the Terminal, not the R console, and then the R console needs to be restarted.
    – gakera
    Oct 11, 2010 at 20:28
  • 1
    Worked for problems with the rJava package too. Sep 21, 2012 at 9:32
  • 3
    This didn't work for me on OSX 10.9.5. I am actually on a German computer and so echo $LANG returns de_DE.UTF-8. I tried this in place of en-US.UTF-8 and also your answer exactly as-is - neither had any effect.
    – n1k31t4
    Oct 20, 2015 at 10:40
  • 1
    Please edit this answer to tell people to quit and restart R.
    – Jubei
    Mar 30, 2017 at 16:55
23

Use this command in the R console:

system("defaults write org.R-project.R force.LANG en_US.UTF-8")

Remember to quit and start again R.

8

refer: https://github.com/nerves-project/nerves/issues/376#issuecomment-456939623

If you don't want to permanently set env. variable. do:

$ export LANG=en_US.UTF-8
$ export LC_ALL=$LANG

No need to restart the system.

1
  • Works well. No restart required. Thanks May 20, 2022 at 10:58
0
  • Better Close the entire R studio and Reopen it again will fix that error tar: Failed to set default locale
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.