Applications acts differently locally and on shiny server pro.

I have a set of codes. (sorry cannot produce it since it is huge). But this acts properly locally. But when deployed on shiny server pro, it is not working.

I checked all libraries that are loaded are of same version.

One question, even if libraries are not loaded and there version are different between local and shiny server. Will this effect the application?

Yes, different versions of packages can behave differently.
For the local Shiny app, you might want to check if there are any objects being stored locally, not in Shiny. One easy way to check this is, if you run the app, do you see any objects in the (global) environment?

For package versions, you might be interested in renv or golem (note: not an expert on this)

Thanks. Just to double confirm. Even if libraries are not loaded in the application, they should be same?

FOr example
my app has

library(A) ##----- 3.6 version (both locally and shiny server)
library(B)##----- 3.5 version (both locally and shiny server)
library(C)##----- 3.8 version (both locally and shiny server)

Other libraries that are not loaded in my app

library(X) ##----- 2.6 version - locally and 2.5 version - shiny server
library(Y)##-----  1.6 version - locally and 1.5 version - shiny server
library(Z)##-----  7.6 version - locally and 7.5 version - shiny server

You mean even because of second scenario the apps can behave differently?

Apps can call other apps as dependencies so it is possible that A uses X under the hood.

Also, you are not specifying in which sense they behave differently, maybe your problem is not related to package version differences, is very har to give you any meaningful advice with so little and vague information, we are basically just guessing.

Thanks pathos.

Also I observed one thing, Below is the image of my local R. I can see 20 packages. But on shiny server, i see only 6 packages. Is it because of this? But I Loaded all libraries, but not sure why it is showing only 6 packages. Can you please help?


Hi all,

I think I got the issue. The reason why it is working properly in locally is , when I run the app first app, the app does not work actually (my bad. I did not notice. But libraries are loaded). So when I open the app second time, it works well. So Can you help me here. How do i load the package globally ? Because in shiny server, even though I load the packages, it does not show under global environement

You don't want to load any objects in the global environment for Shiny; you actually want to empty it. I see in the image you uploaded that there are 5 objects, and four functions ('bo...', 'cr...', 'he...,' etc.). Make sure to run rm(list=ls()) before you run the Shiny app. If it doesn't work without rm(list=ls()), that means you had some scripts/code running before running the Shiny app that Shiny leveraged, which shouldn't be the case, because that code is (or should) not be included in the Shiny app unless you specifically included it in ui.R/server.R/app.R (even then, you should empty your environment).

I emptied it actually


Really Strange thing I noticed
I noticed that shiny application works properly when it is loaded for the second time. Not sure why.

Below process i followed

  1. I emptied the global environment. I open the app first time, certain feature is not working

  2. I close the app, clear the global environment. But you see there some libraries loaded.

  3. I open the app again, that feature works properly.

Can anyone tell me what is the issue here?

These are the libraries in ui.r and server.R


means you had some scripts/code running before running the Shiny app that Shiny leveraged,

May I know what u mean?? Is it even possible??:blush::blush:

  • Load a script unrelated to the Shiny app, let's calls it abc.R and you run it, and it saves an object called df

  • Your Shiny app calls for an object called df

  • The Shiny app loads df from the R Studio environment as a result of abc.R

I think i got. I have some source("ABC.R") in my server. Is this what you mean. If so, how to overcome this?

Try integrating it -- I'm not sure if this is the solution because I've never sourced another script in my Shiny apps

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.