How to solve “tar: Failed to set default locale” error on Mac while installing rJava.

Recently had a problem installing rJava on Mac, received an error:

tar: Failed to set default locale

The solution for this is pretty easy, you have to execute in system console:

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

Or in R console:

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

Then restart R/Rstudio. This solution works for me.