Can't deploy shiny from R: Terra package can't be 'built' - Stack Overflow

I'm at a loss a bit as I am new to creatingdeploying ShinyApps. I have an app ready to deploy whi

I'm at a loss a bit as I am new to creating/deploying ShinyApps. I have an app ready to deploy which does not directly use Terra package, but apparently the Leaflet package is dependent on Terra somehow.

I have tried both with and without library("terra") before I run my app, check whether it works, and deploy it, but I keep getting the same error somewhere along deploying.


    ── Deploying to server ──────────────────────────────────────────────────────────────────────────────────────────────────────────
    Waiting for task: 1523094420
      building: Processing bundle: 9984343
      building: Parsing manifest
      building: Building image: 12301650
      building: Installing system dependencies
      building: Fetching packages
      building: Building package: terra
    ## Begin Task Log ###############################################################################################################
    Quarto not found.
    [2025-03-22T02:24:56.611974066+0000] Execute script: packages/build/units.sh
    + set -e
    + apt-get update -qq
    W: : Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
    + apt-get install -y libudunits2-dev
    Reading package lists...
    Building dependency tree...

There's then about 200 lines of additional code where it's installing packages (somewhere?) like cpp11 and crayon etc. But it always ends with:

make: *** [/opt/R/4.3.2/lib/R/etc/Makeconf:200: RcppModule.o] Error 1
ERROR: compilation failed for package ‘terra’
* removing ‘/usr/lib/R/terra’## End Task Log #################################################################################################################
Error: Unhandled Exception: child_task=1523094421 
child_task_status=failed: Error building image: 
Error building terra (1.8-29). Build exited with non-zero status: 1

I'm not sure why it is trying to 'build' terra, since I have it installed and it works well. I don't think I have an oudated package or R version. See session info below

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] terra_1.8-29      rintrojs_0.3.4    sf_1.0-16         tidyr_1.3.1       dplyr_1.1.4       ggplot2_3.5.1     leaflet_2.2.2    
[8] shinythemes_1.2.0 shiny_1.9.1   

I'm at a loss a bit as I am new to creating/deploying ShinyApps. I have an app ready to deploy which does not directly use Terra package, but apparently the Leaflet package is dependent on Terra somehow.

I have tried both with and without library("terra") before I run my app, check whether it works, and deploy it, but I keep getting the same error somewhere along deploying.


    ── Deploying to server ──────────────────────────────────────────────────────────────────────────────────────────────────────────
    Waiting for task: 1523094420
      building: Processing bundle: 9984343
      building: Parsing manifest
      building: Building image: 12301650
      building: Installing system dependencies
      building: Fetching packages
      building: Building package: terra
    ## Begin Task Log ###############################################################################################################
    Quarto not found.
    [2025-03-22T02:24:56.611974066+0000] Execute script: packages/build/units.sh
    + set -e
    + apt-get update -qq
    W: http://cran.rstudio/bin/linux/ubuntu/jammy-cran40/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
    + apt-get install -y libudunits2-dev
    Reading package lists...
    Building dependency tree...

There's then about 200 lines of additional code where it's installing packages (somewhere?) like cpp11 and crayon etc. But it always ends with:

make: *** [/opt/R/4.3.2/lib/R/etc/Makeconf:200: RcppModule.o] Error 1
ERROR: compilation failed for package ‘terra’
* removing ‘/usr/lib/R/terra’## End Task Log #################################################################################################################
Error: Unhandled Exception: child_task=1523094421 
child_task_status=failed: Error building image: 
Error building terra (1.8-29). Build exited with non-zero status: 1

I'm not sure why it is trying to 'build' terra, since I have it installed and it works well. I don't think I have an oudated package or R version. See session info below

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] terra_1.8-29      rintrojs_0.3.4    sf_1.0-16         tidyr_1.3.1       dplyr_1.1.4       ggplot2_3.5.1     leaflet_2.2.2    
[8] shinythemes_1.2.0 shiny_1.9.1   
Share Improve this question asked Mar 22 at 5:09 BeardedantBeardedant 16012 bronze badges 5
  • (1) "I have installed and it works well" is fine on your local machine, that has no impact on how easy it is (not) on the remote system. That package requires at least GDAL, GEOS, and PROJ libraries. You need to check the remote server to know if it has the libraries (shinyapps.io does). (2) leaflet only suggests terra, it does not require it, its dependency should be based on how you are using leaflet. (3) Please include how and to where you are attempting to deploy your shiny app. – r2evans Commented Mar 22 at 5:27
  • Might be related - stackoverflow/q/79478271/646761 , stackoverflow/q/79449381/646761 – margusl Commented Mar 22 at 6:12
  • This might help. It seems like your deployment environment does not have the necessary libraries/binaries to build terra which needs C++ compilation which fails on deploy, but succeeds locally. Maybe adding dependencies.txt helps or editing the App.R binaries. – Tim G Commented Mar 22 at 11:30
  • Thank you, I'll look into the replies. As for the question regarding deployment. rsconnect::deployApp( appDir = 'C:/Users/path/', appFiles = c('app.R', 'shapefile/shinyshp.shp', 'shapefile/shinyshp.dbf', 'shapefile/shinyshp.shx') ) which if I understand correctly deploys to shinyapps.io – Beardedant Commented Mar 22 at 14:53
  • 1 That doesn't really resolve where it's going since you aren't showing account= or server= (which is fine); the default action is to either prompt you for the remote account or to use the last-known server/account. While you don't necessarily need to give us the entire return values, rsconnect::servers() and rsconnect::accounts() might inform or remind you to what server you're deploying your app. Since shinyapps.io says that it explicitly supports the libraries required by terra, I suspect you're going somewhere else. – r2evans Commented Mar 22 at 15:46
Add a comment  | 

1 Answer 1

Reset to default 0

The solution was in updating my Rstudio version from 4.3.2 to 4.4.x

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744324586a4568583.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信