2

While debugging a shiny app, I noticed that the same source code produces slightly different sessionInfo() locally (macOS Catalina 10.15.6) and on the server (Ubuntu 18.04.5 LTS) in terms of packages loaded. I removed all content from the app, leaving only the loading of the packages:

packages <- c("shiny", "shinythemes", "shinycssloaders", "tidyverse",
"ggthemes", "scales", "feather", "sf", "leaflet", "leaflet.extras",
"RColorBrewer")  
lapply(packages, require, character.only = TRUE)

Then printed sessionInfo() both locally and on the server. While both machines share the same source code and the versions of both R and all packages, the results of sessionInfo() differ. On a close look (outputs below), you might notice that the list of "packages loaded via a namespace (and not attached)" are different in that the server does not load:

  1. sourcetools_0.1.7
  2. farver_2.0.3
  3. yaml_2.2.1
  4. plus, on the server, it loads hms_0.5.3 before crosstalk_1.0.1 (unlike the local machine)

Not sure it would be easy for these differences to create an issue as to access an object from "loaded but not attached" packages one has to prefix with them with packagename::.
Nonetheless, I was surprised to see the disparities and wonder what might cause such behaviour and if this is normal.

Output sessionInfo() local: enter image description here

Output sessionInfo()server: enter image description here

If I load the minimum amount of packages, Shiny only, there are the following differences:

  1. server lists xtable followed by jsonlite, while locally the other way around;
  2. server lists yaml and rsconnect, while locally it does not.

Output sessionInfo() local: enter image description here

Output sessionInfo()server: enter image description here

jpinelo
  • 1,414
  • 5
  • 16
  • 28
  • And if you don’t load any packages, or load as few as possible? What *exactly* causes the difference? — [Unrelatedly, don’t use `require`, always use `library`](https://stackoverflow.com/a/51263513/1968). – Konrad Rudolph Oct 12 '20 at 12:16
  • Thanks for the hint @Konrad Rudolph. Loading minimal packages (Shiny only), the list of "loaded but not attached" is still different. Edited the question to document this. – jpinelo Oct 12 '20 at 13:49

1 Answers1

1

‘rsconnect’ is a package used by Shiny Server for deployment. This explains why it’s loaded automatically in an R instance configured for Shiny Server.1

Looking at its dependencies, we see that it imports the ‘yaml’ package. This explains why this package is also loaded. And lastly, it also imports the ‘jsonlite’ package. And since ‘rsconnect’ is loaded as a default package at R startup, this explains why its imports are loaded earlier than those of the ‘shiny’ package, and hence why the package order of sessionInfo is different between your local and server sessions.


1 The value of options('defaultPackages') on the server should include ‘rsconnect’.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214