Closed
Description
Hi, I was trying to publish my shinyapp to shinyapps.io.
At first, I got this problem, and sort of figured it out by setting the encoding of the R object loading from .rda to UTF-8.
But the same problem shows when I have some Chinese character in the app.R file.
In short, the following will work:
However, this will not (adding some Chinese character in the string):
and here's the messages on console:
(I have already set the whole app.R file to UTF-8, but it doesn't work.)
Can you help me with this?
Thanks!
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jmcphers commentedon Sep 27, 2016
Thanks for reporting this! Can you paste the Chinese characters and/or the expression causing the problem into the issue? (We want to be sure we're testing with the same ones when we try to reproduce this, so we'll copy/paste from your text.)
yenzichun commentedon Sep 29, 2016
No problem!
I'll provide an easy example below so that you can reproduce the same issue.
Here's the Chinese character string: "這是一個直方圖"
Note: If I run
shinyApp(ui, server)
on my local machine, then the Chinese characters can be rendered correctly. But when I use thedeployApp()
inrsconnect
, it will show the error.So I'm guessing as long as the app.R file contains Chinese character, the server can't parse it correctly (even the file is in UTF-8 encoding).
If you need any further help to test Chinese character, please let me know. :)
jmcphers commentedon Oct 4, 2016
Unfortunately I was not able to reproduce this! I deployed your app from a Windows machine without any problems.
https://jonathan.shinyapps.io/shinychars/
Can you paste your RStudio version and sessionInfo()?
yenzichun commentedon Oct 4, 2016
Absolutely, @jmcphers .
https://yenping.shinyapps.io/chinese_char_demo/
Here's my RStudio version and sessionInfo():
BTW, did you deploy the app successfully with one .R file (app.R), or deploy it with separate files (ui.R and server.R)?
I deployed with only one .R file instead of separate files as it did in the tutorial page.
Hope this information would help. Thanks!!
jmcphers commentedon Oct 5, 2016
Looks like you're on an older version of the package -- rsconnect 0.4.5 is the latest. Do you still see the error with the newest version?
yenzichun commentedon Oct 6, 2016
Unfortunately the error still exists after installing the latest version of
rsconnect
... :(I loaded the
shiny
,dplyr
,highcharter
, andrsconnect
packages, randeployApp()
,and these are warning messages during deploying.
Where could I possibly do wrong?
I will appreciate your help with this situation..
Here's my complete app.R file that was deployed to shinyapps.io:
https://yenping.shinyapps.io/hchart/
sessionInfo():
tkomde commentedon Nov 11, 2016
Hi,
I have the same error (fail lint(), dependent libraries aren't installed) on Japanese UTF-8 characters. The errors occur both my file and following official script (https://github.com/rstudio/shiny-examples/tree/master/022-unicode-chinese). My file is attached (please rename .txt to .R).
app.txt
Regards,
kevinushey commentedon Nov 11, 2016
Can you try explicitly marking the encoding as UTF-8? You should be able to do so with:
I can reproduce the errors seen when working within a Japanese locale + the default encoding option set (
native.enc
); changing the default encoding toUTF-8
seems to resolve the issue. Nonetheless, we should see if we can make this more explicit in thersconnect
APIs.tkomde commentedon Nov 14, 2016
Hi, Kevin
Thank you for your reply.
By applying ’options(encoding = "UTF-8")’, I can upload project without error!
As I have seen following article, I didn't try setting options(encoding).
http://shiny.rstudio.com/articles/unicode.html
Better to guide the following might be helpful.
tmp.enc <- options()$encoding
options(encoding = "UTF-8")
deployApp()
options(encoding = tmp.enc)
Regards,
kevinushey commentedon Nov 14, 2016
I wonder if
rsconnect
should operate in the same way asshiny
; that is, assume that any files to be deployed will using UTF-8 encoding?Perhaps we can have an option
rsconnect.encoding
, defaulting toUTF-8
, and users can reset back to e.g.native.enc
if so desired?tkomde commentedon Nov 14, 2016
Yes, that helps much.
When I develop shiny applications using Japanese characters, I change the encoding to UTF-8 every times. So "rsconnect.encoding, defaulting to UTF-8" is welcome for me, and I will use default setting every time :) .
kevinushey commentedon Nov 15, 2016
@jin-tkomoda: one other option that might be useful here -- what if you try setting
options(encoding = "UTF-8")
in your .Rprofile? (Ie, in an R file at~/.Rprofile
).This will tell R to assume that files are saved with UTF-8 encoding, and so the default behavior of the various 'read' routines will assume the files are saved with UTF-8 encoding (as opposed to the system encoding).
Of course, R's handling of UTF-8 strings has some pitfalls on Windows so this will be a bandaid more than anything.
tkomde commentedon Nov 16, 2016
Normally (of my usecase), all .R files are UTF-8. But some CSVs and some text-stream contain japanese local encodings, so it is unsuited for default setting.
cderv commentedon Aug 10, 2017
Hi,
@kevinushey is there any news on this ?
I encountered the same issue. It seems to come from
packrat
, used byrsconnect
. The function which parses R files for dependencies is at the bottompackrat:::fileDependencies.R
and useparse(file, n = -1L)
. Error comes from there.base::parse
seems to use R optionencoding
and when set tonative.enc
the default, it is not working, even if the file is UTF-8.You could try
parse("app.R")
to reproduce the parsing error with your previous example. If you open your file explicitly with UTF-8, it should workparse(file("app.R", encoding = "UTF-8"), n = -1L)
.Will work on a reprex to help.
Not sure how to deal with this. Encoding issue is not easy. I will open an issue in
packrat
too because the cause is there.kevinushey commentedon Aug 10, 2017
I think we want to specify the encoding directly in the
parse()
call, not necessarily by creating afile()
connection with the encoding supplied.Note that
options(encoding = "UTF-8")
does not means "assume text content from connections is UTF-8"; rather, it means "attempt to re-encode text content from connections to UTF-8". This is separate from the behavior ofparse(..., encoding = "UTF-8")
where it does mean "assume strings are UTF-8".Note that the default argument we have is
parse(encoding = "unknown")
; that is, we don't usegetOption("encoding")
here. This partially reflects the difference in behaviors.Here's a test script that illustrates this:
And the output I see:
tl;dr: Packrat should probably try parsing with
parse(encoding = "UTF-8")
.cderv commentedon Aug 11, 2017
When I try that with French on Windows, things are different as the file is not written initially in UTF-8 if I play your example
results
If I try to force writing to UTF-8 to create a UTF-8 file as
app.R
in shiny apps which needsUTF-8
file, I think theparse(encoding = "UTF-8")
should work inpackrat
results
Initially I was thinking of using
file()
withencoding
because I tested it on a frenchapp.r
file with accentuated words in it (including column names). This is an example whereparse(encoding = "UTF-8")
did not manage to parseResults
file is being parsed.
packrat
can then guess dependencies.In this case, I need
file(encoding = "UTF-8")
. Not sure to understand every bit of how R deals with encoding.It could be an edge case, and I think the main solution is to set in
packrat
parse(encoding = "UTF-8)
or to be able to passencoding
param through.Session Info
Wang-CODEPROJECT commentedon Aug 25, 2019
Hi, I have a error when I connect my RStudio with shinyapp.io . It tells me:
Error in curl::curl_fetch_memory(url, handle = handle) :
schannel: CertGetNameString() failed to match connection hostname (api.shinyapps.io) against server certificate names
In addition: Warning message:
In readLines(certificateFile, warn = FALSE) :
invalid input found on input connection 'C:/Program Files/R/R-3.6.1/library/rsconnect/cert/cacert.pem'
Timing stopped at: 0.01 0.02 0.94
How can I solve this?
BroVic commentedon Sep 18, 2019
Hello all, let me join in the fray.
I have seen this warning
Now, I know that
SomeFile.r
has certain non-ASCII characters in it and my code parses this file withscan()
. Furthermore, I am inpackrat::on()
and equally have a Shiny app in the same project. However, I suspect that packrat may be the issue as the warnings were thrown after a call topackrat::status()
- 21 warnings in all and one for each file with the strange characters.seabass20 commentedon Apr 21, 2020
Hi! Any updates on the best way to do this? My ShinyApp reads in several csv files, most of them with non-ASCII characters (german Umlaute). I have saved all of the relevant r-scripts and csv files in UTF-8 encoding, and have also set options(encoding = "UTF-8") before deploying the App, but I still get this error message.
hadley commentedon Feb 24, 2023
Should be fixed by rstudio/packrat#647