Same docker image gives different results with RStudio and Shiny on read.table

I have a shiny application which I run in a docker image. I can also run the same application with Rstudio-server in a docker image. They give different results on a call to read.table. (They are looking at the same file in the same directory - I have the directory mounted.) The RStudio version succeeds. The shiny version reads without error but returns a data.frame with zero rows (instead of about 2000). If I run the same code in shiny-server outside of the docker it runs fine. I am not sure how to proceed to debug this. Any ideas would be appreciated. (My only guess is that the profile for the 'shiny' user is somehow different than the profile for the 'rstudio' user, and that this affects the behavior of the read.table() function. I have no idea if that guess is correct or how to compare the user profile / user options of the different users.)

Is the docker image available anywhere?

The docker image that exhibits the problem has some proprietary code so it's a bit problematic to provide generally. (I might be able to provide it to RStudio the company.) I am also trying to see if the problem disappears if I make some changes (hopefully improvements) to my Docker files, e.g. getting the latest RStudio and Shiny. I will update this thread with any updates. Thanks for the interest.

Hi Carson,
Upgrading my docker image to use R 3.6 and the latest versions of RStudio-server and shiny-server did not fix the problem. Also, I was able to remove almost all extraneous code and preserve the discrepancy, i.e. I have a "minimal reproducible example" of the problem.
Minimal in the sense that the shiny app is quite trivial. The docker image is fairly big.
Since you are at RStudio can I send you the Dockerfiles and the app files?
Please let me know the best way to proceed.


Resolved (I think)
The locale for the application differs depending on whether it is run via rstudio-server or shiny-server. I determined this by comparing the output of sessionInfo() for the two. Since the application runs as I want under the rstudio-server locale setting, I modified the shiny app so that the first thing that the shinyServer() (anonymous) function does is to make Sys.setlocale() calls to change the locale settings. Out of curiosity I kept track of which particular setting seems to modify the behavior. In my case the relevant setting was changing the setting for "LC_CTYPE" from "C" to "en_US.UTF-8". The documentation for read.table() does say that its behavior is affected by the "current locale".

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.