Installing R on Mac - Warning messages: Setting LC_CTYPE failed, using "C"

MacosRInstallation

Macos Problem Overview


I would like install R on my laptop Mac OS X version 10.7.3

I downloaded the last version and I double click on it and it was installed, when i start up I get the following error, I searched in internet but I could not solve the problem, any help would be appreciated

the errors are >During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
[R.app GUI 1.50 (6126) x86_64-apple-darwin9.8.0]

>WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly. [History restored from /Users/nemo/.Rapp.history]

Macos Solutions


Solution 1 - Macos

  1. Open Terminal
  2. Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8
  3. Close Terminal (including any RStudio window)
  4. Start R

For someone runs R in a docker environment (under root), try to run R with below command,

LC_ALL=C.UTF-8 R
# instead of just `R`

Solution 2 - Macos

Setting locales in terminal resolved the issue for me. Open the terminal and

  1. Check if locale settings are missing

     > locale
     LANG=
     LC_COLLATE="C"
     LC_CTYPE="UTF-8"
     LC_MESSAGES="C"
     LC_MONETARY="C"
     LC_NUMERIC="C"
     LC_TIME="C"
     LC_ALL=
    
  2. Edit ~/.profile or ~/.bashrc

     export LANG=en_US.UTF-8
     export LC_ALL=en_US.UTF-8
    
  3. Run . ~/.profile or . ~/.bashrc to read from the file.

  4. Open a new terminal window and check that the locales are properly set

     > locale
     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"
    

Solution 3 - Macos

Just open the R(software) and copy and paste

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

Hope this will work fine or use the other method

open(on mac): Utilities/Terminal copy and paste

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

and close both terminal and R and reopen R.

Solution 4 - Macos

I found slightly different problem running R on through mac terminal, but connecting remotely to an Ubuntu server, which prevented me from successfully installing a library.

The solution I have was finding out what "LANG" variable is used in Ubuntu terminal

Ubuntu > echo $LANG
en_US.TUF-8

I got "en_US.TUF-8" reply from Ubuntu.

In R session, however, I got "UTF-8" as the default value and it complained that LC_TYPEC Setting LC_CTYPE failed, using "C"

R> Sys.getenv("LANG")
"UTF-8"

So, I tried to change this variable in R. It worked.

R> Sys.setenv(LANG="en_US.UTF-8")

Solution 5 - Macos

Tks Ramon Gil Moreno. Pasting in Terminal and then restarting R Studio did the trick:
write org.rstudio.RStudio force.LANG en_US.UTF-8

Environment: MAC OS High Sierra 10.13.1 // RStudio version 3.4.2 (2017-09-28) -- "Short Summer"

Ennio De Leon

Solution 6 - Macos

I got same issue on Catalina mac. I also installed the R from the source in following diretory. ./Documents/R-4.0.3

Now from the terminal type

 ls -a 

and open

 vim .bash_profile 

type

export LANG="en_US.UTF-8"

save with :wq

then type

source .bash_profile 

and then open

./Documents/R-4.0.3/bin/R 
./Documents/R-4.0.3/bin/Rscript 

I always have to run "source /Users/yourComputerName/.bash_profile" before running R scripts.

Solution 7 - Macos

On my Mac r is installed in /usr/local/bin/r, add line below in .bash_profile solved the same problem:

alias r="LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 r"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1267127View Question on Stackoverflow
Solution 1 - MacosnassimhdddView Answer on Stackoverflow
Solution 2 - MacosJarno KeskikangasView Answer on Stackoverflow
Solution 3 - Macosuser3512330View Answer on Stackoverflow
Solution 4 - MacosBhoom SuktitipatView Answer on Stackoverflow
Solution 5 - MacosEnnio De LeonView Answer on Stackoverflow
Solution 6 - Macosankit agrawalView Answer on Stackoverflow
Solution 7 - MacosadietsterView Answer on Stackoverflow