I have had this issue for a while. I was working around by not using special characters. However it's high time to solve it.
Issue is very simple: perfectly working app on local run stops working when moved to /srv/shiny-server/
log points excatly at polish sign. Here is a minimal working example:
library(shiny)
library(DT)
library(ggplot2)
df = data.frame(ę = rep(c("group1", "group2"), 50), ć = rnorm(n = 100))
ui <- fluidPage(
# Application title
titlePanel("Encoding example"),
sidebarLayout(
sidebarPanel(
""
),
mainPanel(
plotOutput("Plot")
)
)
)
server <- function(input, output) {
output$Plot <- renderPlot({
ggplot(df, aes(ę, ć)) +
geom_boxplot()
})
}
shinyApp(ui = ui, server = server)
Here is the log:
su: ignoring --preserve-environment, it's mutually exclusive with --login
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) :
/srv/shiny-server/encoding_debugging/app.R:4:17: unexpected input
3: library(ggplot2)
4: df = data.frame(▒^y
^
Error in sourceUTF8(fullpath, envir = new.env(parent = sharedEnv)) :
Error sourcing /srv/shiny-server/encoding_debugging/app.R
Calls: runApp ... shinyAppDir -> shinyAppDir_appR -> appObj -> func -> sourceUTF8
Execution halted
System settings:
> Sys.getenv('LANG')
[1] "en_US.UTF-8"
> Sys.getlocale()
[1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C"
It doesn't allow to have any special characters in variable/column names. How to fix that issue?
I am serving on latest shiny-server on Ubuntu 22.04. All packages are up to date.
Any suggestions?
Best regards Tomasz