Problem reading shapefile in shinyapps.io

Hi experts,

This very minimal application runs fine locally, but fails when deployed to shinyapps.io,
with "Error: An error has occurred. Check your logs or contact the app author for clarification".

The deployed application is in:
https://moacirpedroso.shinyapps.io/tst_shp/

The source appplication and data are in github:

The actual application needs "runtime: shiny". It is included
in the example because without it I was not able to publish to
shinyapps.io.

Please, I need your help to understand what I'm doing wrong.

Thanks,

Moacir.

This is the application and the log from shinyapps.io:


title: "Reprex for read_sf@Shinyapps.io"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny

library(flexdashboard)
library(sf)

Column {data-width=650}

Chart A

plot(read_sf("./br/BRUFE250GC_SIR.shp"))

2020-12-10T14:42:58.999511+00:00 shinyapps[3380706]: Running on host: 6d5126faa508
2020-12-10T14:42:59.010269+00:00 shinyapps[3380706]: Server version: 1.8.4.1-20
2020-12-10T14:42:59.010278+00:00 shinyapps[3380706]: LANG: pt_BR.UTF-8
2020-12-10T14:42:59.010305+00:00 shinyapps[3380706]: R version: 4.0.3
2020-12-10T14:42:59.010342+00:00 shinyapps[3380706]: shiny version: 1.5.0
2020-12-10T14:42:59.010351+00:00 shinyapps[3380706]: httpuv version: 1.5.4
2020-12-10T14:42:59.010351+00:00 shinyapps[3380706]: rmarkdown version: 2.5
2020-12-10T14:42:59.010351+00:00 shinyapps[3380706]: knitr version: 1.30
2020-12-10T14:42:59.010357+00:00 shinyapps[3380706]: jsonlite version: 1.7.1
2020-12-10T14:42:59.010380+00:00 shinyapps[3380706]: RJSONIO version: (none)
2020-12-10T14:42:59.010429+00:00 shinyapps[3380706]: htmltools version: 0.5.0
2020-12-10T14:42:59.200028+00:00 shinyapps[3380706]: Using jsonlite for JSON processing
2020-12-10T14:42:59.010649+00:00 shinyapps[3380706]: Using pandoc: /opt/connect/ext/pandoc2
2020-12-10T14:42:59.203546+00:00 shinyapps[3380706]:
2020-12-10T14:42:59.203548+00:00 shinyapps[3380706]: Starting R with process ID: '327'
2020-12-10T14:42:59.273867+00:00 shinyapps[3380706]:
2020-12-10T14:42:59.273869+00:00 shinyapps[3380706]: Listening on http://127.0.0.1:42629
2020-12-10T14:43:02.087040+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.442696+00:00 shinyapps[3380706]: processing file: tst_shp.Rmd
2020-12-10T14:43:02.446413+00:00 shinyapps[3380706]: label: setup (with options)
2020-12-10T14:43:02.448653+00:00 shinyapps[3380706]: List of 1
2020-12-10T14:43:02.450191+00:00 shinyapps[3380706]: $ include: logi FALSE
2020-12-10T14:43:02.442694+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.450210+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.442695+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.445108+00:00 shinyapps[3380706]:
|
| | 0%
|
|.............. | 20%
2020-12-10T14:43:02.445267+00:00 shinyapps[3380706]: ordinary text without R code
2020-12-10T14:43:02.445673+00:00 shinyapps[3380706]:
|
|............................ | 40%
2020-12-10T14:43:02.445268+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.751521+00:00 shinyapps[3380706]: Linking to GEOS 3.5.1, GDAL 2.2.2, PROJ 4.9.2
2020-12-10T14:43:02.754434+00:00 shinyapps[3380706]:
|
|.......................................... | 60%
2020-12-10T14:43:02.754444+00:00 shinyapps[3380706]: ordinary text without R code
2020-12-10T14:43:02.754579+00:00 shinyapps[3380706]:
|
|........................................................ | 80%
2020-12-10T14:43:02.754445+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.754808+00:00 shinyapps[3380706]: label: unnamed-chunk-1
2020-12-10T14:43:02.760175+00:00 shinyapps[3380706]: Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
2020-12-10T14:43:02.760184+00:00 shinyapps[3380706]: GDAL Error 4: Unable to open /srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.shx or /srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.SHX.Try --config SHAPE_RESTORE_SHX true to restore or create it
2020-12-10T14:43:02.761829+00:00 shinyapps[3380706]: Quitting from lines 21-22 (tst_shp.Rmd)
2020-12-10T14:43:02.762597+00:00 shinyapps[3380706]:
2020-12-10T14:43:02.763769+00:00 shinyapps[3380706]: Warning: Error in : Cannot open "/srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.shp"; The source could be corrupt or not supported. See st_drivers() for a list of supported formats.
2020-12-10T14:43:02.777091+00:00 shinyapps[3380706]: 156:

I would make sure the file is indeed in/srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.shp and that at least
/srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.shx and /srv/connect/apps/tst_shp/br/BRUFE250GC_SIR.dbf are also there. You might also need a .prj.

Maybe you could list.files() in /srv/connect/apps/tst_shp/br/ to debug.

Hi, @etiennebr, thanks for the answer.

Yes, locally I've doubled checked that all four files( .prj, .shp, ,dbf, and .shx) are in the directory.
To deploy an app to shinyapps.io, I only have to click the "Publish" button and make sure that all
needed files are selected. RStudio does the deploying and I don´t have access to the directory
structure in their server. Besides, it runs fine locally.

did you make sure all needed files are selected ?
rsconnect wont guess you need the other files as they are not named in your code

1 Like

Well, thanks, @nirgrahamuk , I was pretty sure I had checked it, but... I'll re-publish it and post what happens this time. Thanks.

@nirgrahamuk, I just made shure all needed files were included, as can be seen in the attached picture, but I got the same error. If you have any other suggestion, I would be glad to hear. Thanks

Clipboard03

Clipboard04

This doesn't necessarily show the same error. Would be better to paste us the text of the actual new log please

Although the reprex has another error, I managed to make the actual application work with the recommendations of @nirgrahamuk. Thanks!

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.