shinyapps.io there is no package called ‘sf’

I have an app that runs fine locally but has an error in the logs on shinyapps.io:

Error in loadNamespace: there is no package called ‘sf’

@josh, could this be related a previous cache issue?

1 Like

Hi Eric, I come across this quite often on shinyapps.io. I believe the issue is when not using your library calls at the start of all scripts in a multi script shiny app.

Because I constantly fell foul of this, I tend to now use a single script to publish. If someone could clearly state how shinyapps requires a multi script setup to be organised, I'd greatly appreciate it (without sending me to the help documentation).

1 Like

@ericpgreen this could be a package cache issue. In the shinyapps.io console select the application > Settings > Advanced > Build Settings. Switch off Package Cache.
sf is likely a dependency of another package.

@m_merciless you can explicitly use the library() function at the start of a script (or perhaps stated in a global.R file) to load the full package once when the app launches. You can also use double colon (package::functionname) to state the package when calling a function, this approach helps to keep track of the package that the function you require is from, but may not be good practice for packages used heavily (due to all the extra typing).

2 Likes

Adding an explicit library() call for this dependency worked.

If a package doesn't declare it's dependency upon sf, then the rsconnect, when it is determining the packages that are used, doesn't know to include sf. The work around is to explicitly include library(sf) in your code. The fix is to find the package that doesn't declare the dependency and request the author fix it.

1 Like

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