LC_CTYPE failed,

I am trying the use R terminal or terminal from Mac according to the codes below.

#SBATCH -o slurm.%N.%j.out
#SBATCH -e slurm.%N.%j.err
#SBATCH --partition fast
#SBATCH --mem 1500GB
##SBATCH --cpus 300
module load r/4.1.1
Rscript scenic_terminal.R

When it reads "Rscript scenic_terminal.R", I receive the error below.

Setting LC_CTYPE failed, using "C"

Error: RStudio not running

Execution halted

Do you have any idea why I get this error and how can I solve it.


It's a "locale" issue (a set of parameters that defines the user's language, region).
I guess your terminal (Mac) comes with your locale settings.

On stackoverflow (macos - Installing R on Mac - Warning messages: Setting LC_CTYPE failed, using "C" - Stack Overflow), they suggest to open your terminal and write:

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

You can also try with something like:

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

module load r/4.1.1
Rscript scenic_terminal.R