Using browser()
inside an observer to do debugging causes an error in recent versions of Shiny. It worked without a problem in versions 0.12.2 or older. The error is Error in gregexpr(calltext, singleline, fixed = TRUE) : regular expression is invalid UTF-8
library(shiny)
ui <- fluidPage(
selectInput(inputId = "choice", "Choices", LETTERS[1:2])
)
server <- function(input, output, session) {
observe({
input[["choice"]]
browser() # Doesn't error if this line is commented.
})
}
shinyApp(ui = ui, server = server)
Hmm, I don't get this... Try starting with a clean working environment and re-installing? Or tell me how I can repro it...
> library(shiny)
>
> ui <- fluidPage(
+ selectInput(inputId = "choice", "Choices", LETTERS[1:2])
+ )
> server <- function(input, output, session) {
+ observe({
+ input[["choice"]]
+ browser() # Doesn't error if this line is commented.
+ })
+ }
>
> shinyApp(ui = ui, server = server)
Listening on http://127.0.0.1:3607
Called from: observerFunc()
Browse[1]> n
Called from: observerFunc()
Browse[1]> n
Called from: observerFunc()
Browse[1]> n
Called from: observerFunc()
Browse[1]>
> devtools::session_info("shiny")
Session info ----------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin13.4.0
ui RStudio (1.0.125)
language (EN)
collate en_US.UTF-8
tz Europe/Lisbon
date 2016-11-20
Packages --------------------------------------------------------------
package * version date source
digest 0.6.10 2016-08-02 cran (@0.6.10)
htmltools 0.3.5 2016-03-21 CRAN (R 3.3.0)
httpuv 1.3.3 2015-08-04 CRAN (R 3.3.0)
jsonlite 1.1 2016-09-14 CRAN (R 3.3.0)
mime 0.5 2016-07-07 CRAN (R 3.3.0)
R6 2.2.0 2016-10-05 cran (@2.2.0)
Rcpp 0.12.7.5 2016-11-07 Github (RcppCore/Rcpp@88ebc36)
shiny * 0.14.2 2016-11-01 CRAN (R 3.3.0)
sourcetools 0.1.5 2016-09-15 CRAN (R 3.3.0)
xtable 1.8-2 2016-02-05 CRAN (R 3.3.0)
I found out that this only happens if the application is run in RStudio on Windows. If I run the example using RGui in Windows instead, it doesn't happen. Also, it doesn't happen if the application is run in RStudio but in a Debian operating system.
How should I report this? There's no public issue tracker for RStudio. I am using version 1.0.44, currently the newest released version of the IDE.
RStudio IDE team member here -- I've reproduced this and logged a bug on the RStudio side for us to take a look. Thanks for reporting!
Thanks both!
I still reproduce this in my own code within an observer in Shiny as of today.
Same error message for me still today.
Same Issue for me today.
Everything was working fine. No issues and then BAM. this error.
Error in gregexpr(calltext, singleline, fixed = TRUE) :
regular expression is invalid UTF-8
Exactly the same problem!
the solution was to "Reopen with Encoding ..."
RStudio takes at least a year to fix most bugs. They're grossly understaffed.
@DarioS: for what it's worth, this issue appears to be resolved in R 3.4.1 (at least, I wasn't able to reproduce on my Windows VM when running with the 64bit version of R 3.4.1). Nonetheless, we're still tracking this issue for the v1.1 release of RStudio and hope to have it fixed there as well.
Although the error isnt really harmful, I am still getting it with R 3.5.2 and RStudio 1.1.463
Browse[1]> c
Error in gregexpr(calltext, singleline, fixed = TRUE) :
regular expression is invalid UTF-8
Error in gregexpr(calltext, singleline, fixed = TRUE) :
regular expression is invalid UTF-8
I am still getting the same error, even not always, with R 3.6.1 and RStudio 1.2.5001
Error in chartr("ŠŽšžŸÃ\200Ã\201ÂÃÄÅÇÃ\210ÉÊËÌÃ\215ÃŽÃ\217Ã\220ÑÒÓÔÕÖÃ\231ÚÛÜÃ\235à áâãäåçèéêëìÃîïðñòóôõöùúûüýÿ", :
'old' is longer than 'new'
Called from: chartr("ŠŽšžŸÃ\200Ã\201ÂÃÄÅÇÃ\210ÉÊËÌÃ\215ÃŽÃ\217Ã\220ÑÒÓÔÕÖÃ\231ÚÛÜÃ\235à áâãäåçèéêëìÃîïðñòóôõöùúûüýÿ",
"SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy",
string)
Error during wrapup: regular expression is invalid UTF-8
Most helpful comment
RStudio IDE team member here -- I've reproduced this and logged a bug on the RStudio side for us to take a look. Thanks for reporting!