Shiny App crashes with local package on shinyapps.io

Hi RStudio Community,

when trying to deploy a shiny app to shinyapps I am using a private Github repo simonskok/IBSignals, but shinyapps has access to it with devtools::install_github("simonskok/IBSignals", auth_token = "****************************************") - everything works fine locally, but the app crashes online with exit error status 1). Below is the output of rsconnect::showLogs():

2022-07-20T16:52:57.099616+00:00 shinyapps[6668965]: Downloading GitHub repo simonskok/IBSignals@HEAD
2022-07-20T16:52:57.099539+00:00 shinyapps[6668965]:
2022-07-20T16:52:57.099484+00:00 shinyapps[6668965]: intersect, setdiff, setequal, union
2022-07-20T16:52:58.097913+00:00 shinyapps[6668965]: * checking for file ‘/tmp/RtmppoTKYh/remotes1c677c892c/simonskok-IBSignals-d1b7cb6b452dd67b662ed9ce36cbc486c30ad815/DESCRIPTION’ ... OK
2022-07-20T16:52:58.097959+00:00 shinyapps[6668965]: * preparing ‘IBOptionsSignals’:
2022-07-20T16:52:58.097846+00:00 shinyapps[6668965]:
2022-07-20T16:52:58.098005+00:00 shinyapps[6668965]: * checking DESCRIPTION meta-information ... OK
2022-07-20T16:52:58.098142+00:00 shinyapps[6668965]: Omitted ‘LazyData’ from DESCRIPTION
2022-07-20T16:52:58.098099+00:00 shinyapps[6668965]: * checking for empty or unneeded directories
2022-07-20T16:52:58.098052+00:00 shinyapps[6668965]: * checking for LF line-endings in source and make files and shell scripts
2022-07-20T16:52:58.098228+00:00 shinyapps[6668965]: WARNING: Added dependency on R >= 3.5.0 because serialized objects in
2022-07-20T16:52:58.098269+00:00 shinyapps[6668965]: serialize/load version 3 cannot be read in older versions of R.
2022-07-20T16:52:58.098188+00:00 shinyapps[6668965]: NB: this package now depends on R (>= 3.5.0)
2022-07-20T16:52:58.098357+00:00 shinyapps[6668965]: ‘IBOptionsSignals/inst/extdata/OANDA_Data/EU_Assets.RData’
2022-07-20T16:52:58.098316+00:00 shinyapps[6668965]: File(s) containing such objects:
2022-07-20T16:52:58.098392+00:00 shinyapps[6668965]: * building ‘IBOptionsSignals_0.1.0.tar.gz’
2022-07-20T16:53:01.101200+00:00 shinyapps[6668965]:
2022-07-20T16:53:01.101259+00:00 shinyapps[6668965]: Warning in i.p(...) :
2022-07-20T16:53:01.101562+00:00 shinyapps[6668965]: Execution halted
2022-07-20T16:53:01.101607+00:00 shinyapps[6668965]: Shiny application exiting ...
2022-07-20T16:53:01.101359+00:00 shinyapps[6668965]: Error in value[3L] :
2022-07-20T16:53:01.101400+00:00 shinyapps[6668965]: Failed to install 'IBOptionsSignals' from GitHub:
2022-07-20T16:53:01.101454+00:00 shinyapps[6668965]: unable to install packages
2022-07-20T16:53:01.101511+00:00 shinyapps[6668965]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-07-20T16:53:01.101307+00:00 shinyapps[6668965]: 'lib = "/opt/R/4.1.2/lib/R/library"' is not writable

What does this mean or how can I correct that: 'lib = "/opt/R/4.1.2/lib/R/library"' is not writable?

Output of rsconnect::appDependencies() shows all other dependencies are from CRAN.

I guess you need to add a writable libPath on app or session start e.g. via .libPaths(c(tempdir(), .libPaths()))

Please see my related answer here:

1 Like

Thank you for your answer, it removes the error message, however the problem remains that it does load the package when opening the app, so I can not use the functions from it. What must I include in the call library(IBOptionsSignals), so that shinyapp will recognise the package location?

Putting the following in global.R should make it work:

.libPaths(c(tempdir(), .libPaths()))
devtools::install_github("simonskok/IBOptionsSignals", auth_token = "****************************************") 
library(IBOptionsSignals)

After following your suggestion the problem remains (Time_Since_US_Market_Open_Close is a function from my local package, the first one used in the shiny app)...below is a section of the output of rsconnect::showLogs()

2022-07-26T10:28:09.308324+00:00 shinyapps[6668965]: Shiny application starting ...
2022-07-26T10:28:09.308391+00:00 shinyapps[6668965]: could not find function "Time_Since_US_Market_Open_Close"
2022-07-26T10:28:09.308356+00:00 shinyapps[6668965]: Error in value[3L] :
2022-07-26T10:28:09.308425+00:00 shinyapps[6668965]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->

What else could I try to load the package at the start of the shinyapp?

It seems like you are calling that function before the library is loaded (library(IBOptionsSignals)).

But the global.R looks like that:

.libPaths(c(tempdir(), .libPaths()))

suppressMessages(library(shinytoastr))

devtools::install_github("simonskok/IBOptionsSignals", auth_token = "***********************************")

library(IBOptionsSignals)

I assume global.R is run before the app.R, so by that time functions should already be available or not?

Using global.R requires a two-file shiny app (ui.R and server.R) it can't be used along with app.R.

When deploying a single-file shiny app (using app.R) just copy the global code above (or outside) the ui and server function.

Please check the following articles:

https://shiny.rstudio.com/articles/two-file.html

https://shiny.rstudio.com/articles/scoping.html

I really appreciate your help, we just be so close to the solution, but now after inserting the code back into the app.R the logs say:

2022-07-26T12:32:21.484823+00:00 shinyapps[6668965]: Shiny application exiting ...
2022-07-26T12:32:21.484649+00:00 shinyapps[6668965]: * DONE (IBOptionsSignals)
2022-07-26T12:32:21.484735+00:00 shinyapps[6668965]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-07-26T12:32:21.484696+00:00 shinyapps[6668965]: Error in value[3L] : could not find function "%!>(MISSING)%!"(MISSING)
2022-07-26T12:32:21.484778+00:00 shinyapps[6668965]: Execution halted

What is this "%!>(MISSING)%!"(MISSING)?
Otherwise, locally the app workes without an issue.

Solved, now the problem is

Error in value[3L] : missing value where TRUE/FALSE needed.

Any idea how I can find out what is causing that as it is not a function?

"%!>(MISSING)%!"(MISSING) was because of the pipe operator from magrittr/dplyr package not being loaded.

is often caused by a input$something being NULL on session start and used in an if-statement - this usually can be avoided by placing req(input$something) above that if.