Could not find function "%OR%" in Shiny App

I built a Shiny application that works A ok within the IDE but produces the following error when opened by an end user:

Warning: Error in %OR%: could not find function "%OR%"
    1: runApp

Unfortunately, I cannot provide a reprex for this. I'm mainly just interested to know if anyone has encountered this error before. If so, what was the source and how did you resolve it?

The string "%OR%" does not appear anywhere in the code, and "OR" only exists within text strings (i.e., not adjacent to () to create a function call). I am using binary operators in JavaScript and R conditions, but that's the only programmatic use of an OR -- I'm using "||" and "|", respectively, not the word.

Is there, perhaps, a package that uses %OR%?

It's likely something in your IDE session that is not in namespace for the app. Try the IDE from a fresh session to confirm—it may just need a library() call.

I agree--something is missing from the shiny user namespace. The app worked from a fresh session/empty namespace. I'm using renv to handle dependencies. I can't quite understand how a function within a library would be recognized in a dev environment (IDE) but not in a production environment (https/Shiny Server) with the same library() calls in the code.

Maybe a pathing issue? Is it possible as a non-server owner to verify that the shiny user is loading from the correct repo (i.e., the renv) AND not loading any dependencies prior to loading the renv?

Get the script in production to output its libPath?

DEV:
[1] "/renv/library/R-4.1/x86_64-pc-linux-gnu"
[2] "/opt/R/4.1.2/lib/R/library"

PROD:
[1] "/renv/library/R-4.0/x86_64-pc-linux-gnu"
[2] "/opt/R/4.0.3/lib/R/library"

It looks like the shiny user is running R version 4.0.* and my dev is running R version 4.1.*. Instead of trying to coerce the R version with renv::settings$r.version("4.1.2") which did not work for me, I deprecated the R version in the lockfile to match the shiny user's.

# Changed the R version in RStudio first, then restored from the lockfile
renv::restore()
# Updated the lockfile to use the shiny user version of R
renv::settings$r.version("4.0.3")
# VOILA
1 Like

This topic was automatically closed 7 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.