Skip to content

Error Knit ioslides_presentation (R 4.3) #2480

Closed

Description

@apalacio9502

Hello,

I upgraded to the latest version of R to 4.3 and now when I Knit an Rmarkdown file where the output is ioslides_presentation the following error occurs. I tried using the default ioslides_presentation template and the error also happens.

Error in gsub("\\D", "", system2("chcp", stdout = TRUE)) : 
  input string 1 is invalid
Calls: <Anonymous> -> <Anonymous> -> overlay -> gsub
Además: Warning message:
In gsub("\\D", "", system2("chcp", stdout = TRUE)) :
  unable to translate 'P<a0>gina de c<a2>digos activa: 850' to a wide string
Ejecución interrumpida
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=Spanish_Colombia.utf8 
[2] LC_CTYPE=Spanish_Colombia.utf8   
[3] LC_MONETARY=Spanish_Colombia.utf8
[4] LC_NUMERIC=C                     
[5] LC_TIME=Spanish_Colombia.utf8    

time zone: America/Bogota
tzcode source: internal

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

loaded via a namespace (and not attached):
 [1] compiler_4.3.0  fastmap_1.1.1  
 [3] cli_3.6.1       htmltools_0.5.5
 [5] tools_4.3.0     rstudioapi_0.14
 [7] yaml_2.3.7      rmarkdown_2.21 
 [9] knitr_1.42      xfun_0.39      
[11] digest_0.6.31   rlang_1.1.0    
[13] evaluate_0.20  

Regards,

Activity

  1. cderv commented on Apr 28, 2023

    @cderv
    Collaborator

    It seems like a encoding issue with what

    system("chcp", stdout = TRUE)

    returns.

    Maybe related to R being UTF8 by default on windows now.

    I have submitted #2481 to "fix" this. I don't think this is needed anymore and it won't call this system() call anymore.

    I'll check everything is still working find.

    Otherwise, we need to see how to adapt system() calls - but I can't reproduce the issue yet. Probably related to your locale.

  2. cderv commented on Apr 28, 2023

    @cderv
    Collaborator

    Erratum: I can reproduce now -

    gsub("\\D", "", system2("chcp", stdout = TRUE))
    #> Warning in gsub("\\D", "", system2("chcp", stdout = TRUE)): unable to translate
    #> 'Page de codes active<a0>: 65001' to a wide string
    #> Error in gsub("\\D", "", system2("chcp", stdout = TRUE)): input string 1 is invalid

    It seems to be related now to this change in R 4.3 (wch/r-source@e4e4b75) from NEWS

    Regular expression functions now check more thoroughly whether their inputs are valid strings (in their encoding, e.g. UTF-8)

    So it seems very new, and it seems we need to make system() correctly return encoding. But not sure how.

    processx does it right now

    processx::run("chcp")$stdout
    #> [1] "Page de codes active: 850\r\n"

    but system call does differently

    > system("chcp", intern = TRUE)
    [1] "Page de codes active\xa0: 1250"
    > system2("chcp", stdout = TRUE)
    [1] "Page de codes active\xa0: 1250"

    with different value it seems.

    Not sure how to handle it. We probably need to convert now result of system() to the expected encoding before doing any processing.

    > x <- system("chcp", intern = TRUE)
    > codepage <-utils::readRegistry("SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage")$ACP
    > y <- iconv(x, from = codepage, to = "UTF-8")
    > gsub("\\D", "", y)
    [1] "1250"

    I still think doing this is not needed anymore for ioslide to work though... hence the current PR

  3. github-actions commented on Nov 1, 2023

    @github-actions

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

  4. locked as resolved and limited conversation to collaborators on Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions