Deployment fails on shinyapps.io because of terra

Hi,

I'm trying to publish a shiny app on shinyapps.io. The app has been developed using golem. I use the last version of R and Rstudio and all packages are up to date.
Unfortunately, when I try to publish using rsconnect, the dependencies installation fails on terra with this error :

`
/usr/include/gdal/gdal_priv.h:2506:26: note: candidate expects 2 arguments, 3 provided
make: *** [/opt/R/4.6.1/lib/R/etc/Makeconf:199: gdal_multidimensional.o] Error 1
ERROR: compilation failed for package ‘terra’

  • removing ‘/usr/lib/R/terra’## End Task Log ################################################################
    Erreur : Unhandled Exception: child_task=1713770840 child_task_status=failed: Error building image: Error building terra (1.9-34). Build exited with non-zero status: 1
    Exécution arrêtée
    `

EDIT: I just tried on a linux computer. Same result... which is not really surprising

Thank you for your help

4 Likes

That looks like a problem with GDAL on Posit's side to me. @kyle_hekhuis would you be able to take a look?

1 Like

I have just hit the same issue. In my case terra is required as a dependency to leaflet. The deployment was working perfectly well until I recently updated R and so re-installed latest versions of all packages. My previous version of terra was 1.9-1. Current version is 1.9-34.

And yes, I agree, looks like a GDAL issue on server side.

2 Likes

Here is the exact compile error I am getting from the server:

* installing *source* package ‘terra’ ...
** this is package ‘terra’ version ‘1.9-34’
** package ‘terra’ successfully unpacked and MD5 sums checked
** using staged installation
configure: WARNING: to support parallel processing install TBB devel or update the PKG_CONFIG_PATH environment variable
** libs
specified C++17
using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0’
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0’
using C++17
gdal_multidimensional.cpp: In member function ‘bool SpatRaster::open_gdal_multidim(void*&, size_t)’:
gdal_multidimensional.cpp:1090:49: error: no matching function for call to ‘GDALMDArray::AsClassicDataset(__gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long unsigned int>, long unsigned int>::value_type&, std::shared_ptr<GDALGroup>&)’
 1090 |         GDALDataset *cds = arr->AsClassicDataset(source[src].m_dims[0], source[src].m_dims[1], root);
      |                            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from spatVector.h:24,
                 from spatRaster.h:20,
                 from spatRasterMultiple.h:18,
                 from gdal_multidimensional.cpp:18:
/usr/include/gdal/gdal_priv.h:2506:26: note: candidate: ‘virtual GDALDataset* GDALMDArray::AsClassicDataset(size_t, size_t) const’
 2506 |     virtual GDALDataset* AsClassicDataset(size_t iXDim, size_t iYDim) const;
      |                          ^~~~~~~~~~~~~~~~
/usr/include/gdal/gdal_priv.h:2506:26: note:   candidate expects 2 arguments, 3 provided
make: *** [/opt/R/4.6.1/lib/R/etc/Makeconf:199: gdal_multidimensional.o] Error 1
ERROR: compilation failed for package ‘terra’

@samp Could you take a look at this? Kyle said to ping you instead. Thanks!

Hi Simon

Looks like you have hit a limitation in our system, sorry about that. The version of terra you are using depends on GDAL behavior that was added in GDAL 3.8 but our system is currently using GDAL 3.4. If this is blocking you, you might try pinning to an older version of terra which depends on the older GDAL.

In the meantime, I'll file an issue for our infrastructure to get updated versions of these packages.

Sorry about that!
sam

Hi, thank you! Do you have an estimate of when the updated GDAL version will be deployed to Posit Connect Cloud / shinyapps (I just saw the same problem in Posit Connect Cloud)?

This looks like a terra compilation issue rather than a problem with your Shiny app. The error usually points to a version mismatch between terra and the GDAL libraries on the build server. I'd check the terra version being installed and, if it still fails, contact shinyapps.io support since it may be an issue with their build environment.

We have updated GDAL in Posit Connect Cloud so this app should work there now. Shinyapps.io has not yet been udpated and I don't have an estimate for that yet.

Hopefully Connect Cloud will work for you!

thanks
sam

Sorry for the false alarm, we had to revert this because of an unrelated issue. We are investigating.

I apologize for the back and forth on this.

I am having the same deployment issue, but mine seems to be due to purrr

Hi there, I am having this same issue - I use leaflet which suggests terra and although it all works locally I cannot deploy on shinyapps.io . I was wondering what version of Terra would be compatible with the GDAL on the server side - the CRAN page for terra just mentions GDAL>= 2.2.3

same issue described above with terra, R 4.6.1, and RStudio 2026.07.1
in my case downgraded to R 4.5.3 and used an older renv lockfile to restore package versions -- deploy works again

This looks like a build environment compatibility issue rather than a problem with your Shiny app or the golem framework itself.

The key part of the log is:

ERROR: compilation failed for package 'terra'
...
candidate expects 2 arguments, 3 provided

That usually indicates that the version of terra being compiled is incompatible with the version of GDAL available on the shinyapps.io build server. In other words, the compiler is finding a different GDAL API than the version of terra expects.

A few things you can try:

  • Update terra to the latest CRAN version if you haven't already. There have been fixes for compatibility with newer GDAL releases.
  • If you're already on the latest terra, try pinning an earlier version that is known to work with shinyapps.io. Sometimes the newest package release reaches CRAN before hosted build environments are fully compatible.
  • Make sure your renv.lock (if you're using renv) isn't forcing a problematic terra version.
  • If terra is only used indirectly, check whether another package is pulling in an older or incompatible version.

Since you reproduced the error on another Linux machine, it further suggests this isn't a Windows-specific issue.

It would also be helpful to know:

  • The output of sessionInfo()
  • Your terra version (packageVersion("terra"))
  • Whether you're using renv
  • Whether the app actually uses terra directly or it's just a dependency of another package (e.g. sf, stars, raster, etc.)

With that information, it should be easier to determine whether this is a terra version issue or a compatibility problem with the shinyapps.io build environment.

Are there any updates on when shiny apps.io will be updated? Are there any workarounds in the meantime? I am having the same issues with the gdal and terra versions due to my leaflet maps and am unable to publish.

Sorry for the late reply, I was on vacation !

sessionInfo()
R version 4.6.1 (2026-06-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default
  LAPACK version 3.12.1

locale:
[1] LC_COLLATE=French_France.utf8  LC_CTYPE=French_France.utf8    LC_MONETARY=French_France.utf8
[4] LC_NUMERIC=C                   LC_TIME=French_France.utf8    

time zone: Europe/Paris
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.6.1 tools_4.6.1   

Terra version : 1.9.34

I am not using renv

The app is actually using sf , not terra

We were having the same issue and had success deploying with the {terra} version 1.8-93. Our app was also not using {terra} specifically, but it appears to be a hard dependency of the {raster} package, which is a hard dependency of {leaflet}.

We are also working in an renv and ensured we updated our lockfile before creating the manifest.json to make explicit which {terra} package version to use in the build.

You can run the following in your R console to get and install the package version. We used the binary to avoid local compatibility issues.

download.file(
  "https://packagemanager.posit.co/cran/2026-01-15/bin/macosx/big-sur-arm64/contrib/4.3/terra_1.8-93.tgz",
  destfile = "terra_1.8-93.tgz"
)
install.packages("terra_1.8-93.tgz", repos = NULL, type = "binary")
1 Like

Connect Cloud (Posit Connect Cloud Documentation ) on Posit does not have this issue. I would recommend deploying through them rather than shinyapps.io. I did this with code that was intended to run through Shiny without changing my code, and it still worked through Connect Cloud.

This does look more like an environment/toolchain issue than an application issue. The fact that terra fails while compiling against GDAL, and that the same package builds differently depending on the system libraries available, points in that direction.

It would be useful to know which GDAL version is currently available in the shinyapps.io build image for R 4.6.1, and whether terra 1.9-34 is expected to be compatible with it. If not, a temporary workaround might be to deploy with a known compatible R/package combination until the build image is updated.

For what it's worth, I was running up against the exact same terra/raster GDAL compatibility issue and installing the older, binary version of terra worked perfectly for me.