New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange locale problems in RStudio after update to OsX Mojave #3587

Closed
bakaburg1 opened this Issue Oct 3, 2018 · 18 comments

Comments

Projects
None yet
4 participants
@bakaburg1
Copy link

bakaburg1 commented Oct 3, 2018

I'm having strange problems with RStudio after updating to OsX Mojave.

When I start up a RStudio project I get:

    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_MONETARY failed, using "C" 

Then, if I source() R files with non-english characters like accented vowels, I get an error if I don't remove the encoding = 'UTF-8' option.

If I use the View function special characters get encoded, so àèòù become <c3><a0><c3><a8><c3><b2><c3><b9>

Using plain R I don't get any errors.

How can I solve this? it's pretty annoying especially when save/sourcing R files from RStudio, since it puts encoding = 'UTF-8' by default.

diagnostics-report.txt

System details

RStudio Edition : Desktop
RStudio Version : 1.1.456 
OS Version      :  OsX 10.14
R Version       : 3.5.1
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RSQLite_2.1.1

loaded via a namespace (and not attached):
 [1] httr_1.3.1         magic_1.5-8        ddalpha_1.3.4      tidyr_0.8.1        jsonlite_1.5       sfsmisc_1.1-2      bit64_0.9-7        splines_3.5.1     
 [9] foreach_1.4.4      prodlim_2018.04.18 assertthat_0.2.0   stats4_3.5.1       DRR_0.0.3          blob_1.1.1         yaml_2.2.0         robustbase_0.93-1 
[17] ipred_0.9-6        pillar_1.2.3       backports_1.1.2    lattice_0.20-35    glue_1.2.0         digest_0.6.16      colorspace_1.3-2   recipes_0.1.3     
[25] Matrix_1.2-14      plyr_1.8.4         timeDate_3043.102  pkgconfig_2.0.2    CVST_0.2-2         wesanderson_0.3.6  broom_0.5.0        earth_4.6.3       
[33] caret_6.0-80       purrr_0.2.5        scales_1.0.0       gower_0.1.2        lava_1.6.2         TeachingDemos_2.10 tibble_1.4.2       ggplot2_3.0.0     
[41] withr_2.1.2        nnet_7.3-12        lazyeval_0.2.1     survival_2.42-3    magrittr_1.5       memoise_1.1.0      nlme_3.1-137       MASS_7.3-50       
[49] dimRed_0.1.0       class_7.3-14       tools_3.5.1        stringr_1.3.1      kernlab_0.9-26     munsell_0.5.0      plotrix_3.7-2      bindrcpp_0.2.2    
[57] pls_2.6-0          compiler_3.5.1     RcppRoll_0.3.0     rlang_0.2.2        plotmo_3.4.2       grid_3.5.1         iterators_1.0.9    geometry_0.3-6    
[65] gtable_0.2.0       ModelMetrics_1.1.0 codetools_0.2-15   abind_1.4-5        DBI_1.0.0          reshape2_1.4.3     R6_2.2.2           lubridate_1.7.4   
[73] dplyr_0.7.6        bit_1.1-14         bindr_0.1.1        stringi_1.2.3      Rcpp_0.12.18       rpart_4.1-13       DEoptimR_1.0-8     tidyselect_0.2.4 
@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 3, 2018

What do you see in a terminal if you run locale -a? Do you get a large set of locales printed out?

The diagnostics report contains this:

$LANG
[1] "en_IT.UTF-8"

$LC_CTYPE
[1] "en_IT.UTF-8"

Are those locales available on your system? In the Language and Region macOS preferences pane, what do you have set as the current region?

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 3, 2018

Looks like you cross-posted this. Please don't do this (it duplicates the effort from those who try to help you). https://community.rstudio.com/t/strange-locale-problems-in-r-after-update-to-mojave/15533/6

@kevinushey kevinushey closed this Oct 3, 2018

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 3, 2018

Sorry for cross posting. At the beginning I thought it was an R problem, then I realized it was RStudio specific so I decided to post it as an issue here.

en_IT.UTF-8 is not in the list produced by locale -a and actually it wouldn't make sense if it was because it would be an "Italian sublanguage of English" (WTF??)! The right locale should be it_IT.UTF-8.

The question now is why RStudio is using this hybrid locale since mac os update. The language in the preference pane is ok and the problem seems limited to RStudio. I also updated RStudio to the last version but nothing changed.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 4, 2018

I know that the issue is closed but I found a workaround. (posted also on https://community.rstudio.com/t/strange-locale-problems-in-r-after-update-to-mojave/15533/7)

The problem is confirmed running Sys.getenv()

LANG                                           en_IT.UTF-8
LC_CTYPE                                       en_IT.UTF-8

I don't really know where these setting come from.

The workaround to make everything work is using Sys.setlocale(locale = 'en_US.UTF-8'). But I think it's a problem of RStudio interacting with Mojave.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 5, 2018

Looks like you cross-posted this. Please don't do this (it duplicates the effort from those who try to help you). https://community.rstudio.com/t/strange-locale-problems-in-r-after-update-to-mojave/15533/6

@kevinushey Why the issue was closed? Even if I found a workaround the issue is not solved and is probably RStudio related!

@kevinushey kevinushey reopened this Oct 5, 2018

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 5, 2018

Thanks. I was able to confirm the issue by changing my laptop's region to Italy and attempting to launch RStudio. We'll try to investigate further and figure out what's going on.

@kevinushey kevinushey added this to the v1.2 milestone Oct 5, 2018

@kevinushey kevinushey self-assigned this Oct 5, 2018

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 5, 2018

After setting up the region, the system does update the notion of the locale:

$ defaults read NSGlobalDomain AppleLocale
en_IT

which is odd, since this locale does not exist. I suspect this is where RStudio is getting its notion of the 'default' locale from.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 7, 2018

Running the same code I get it_IT though. And the problem doesn't show up with standalone R.

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 8, 2018

I looked into this more deeply; the issue appears to be that some internal macOS APIs ([NSLocale currentLocale]) always reports the current locale with an en_ prefix, even if the current keyboard layout is set to a non-English layout. defaults read NSGlobalDomain AppleLocale does appear to return the correct output.

This should be fixed in the latest daily builds (http://dailies.rstudio.com); we'd appreciate it if you could install and let us know if the problem indeed does appear to be fixed.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 8, 2018

Apparently the problem seems fixed in the daily! Thanks!

(OT: when I installed the new version the code font reverted to the default, not a big deal, I just wanted to report it. The other settings seem ok)

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 8, 2018

Phew, glad to hear it!

I'm not sure what would've caused the code font to revert but if the newly-set code font does persist on new restarts of RStudio then I think it's okay.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 8, 2018

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 8, 2018

Could you file that as a new issue here on GitHub?

Any chance you could share the project sources wherein you're seeing this issue?

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 8, 2018

One of them yes, no sensitive data/code yet. how should I do it? just upload the project?

@kevinushey

This comment has been minimized.

Copy link
Contributor

kevinushey commented Oct 8, 2018

You can use some cloud service (e.g. Dropbox, OneDrive, Google Drive) to share an archive of the project.

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 8, 2018

ok thanks

@bakaburg1

This comment has been minimized.

Copy link
Author

bakaburg1 commented Oct 8, 2018

I don't know what to say. The problem disappeared, on all project. I'm not able to reproduce it anymore...

@ronblum

This comment has been minimized.

Copy link

ronblum commented Oct 26, 2018

Fix confirmed in RStudio MacOS Desktop 1.1.463. The test was conducted using the following code in a file saved in UTF-8:

print("Dear John")
print("àèòù")
print("Hi there!")

The results were

> print("Dear John")
[1] "Dear John"
> print("àèòù")
[1] "àèòù"
> print("Hi there!")
[1] "Hi there!"

Running this code with English (en_EN), French (fr_FR). and mixed English/French (en_FR). I used French instead of Italian becauseI know how to speak French but not Italian, and I needed a language I understood in order to navigate through menus.

If you find that this is still not working, please update the this ticket. Grazie!

@dfalty dfalty added the verified label Nov 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment