rshinyshinyappsterra

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


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.com/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   

Solution

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