When deploying an R/Shiny application to Tanzu Application Service (TAS) using the r_buildpack on the cflinuxfs4 stack, the staging process fails during the compilation of geospatial R packages such as leaflet, sf, terra, or units.
The staging logs typically contain errors indicating that native system libraries are missing:
configure: error: gdal-config not found or not executable.Configuration failed because libudunits2.so was not found.Could not find a package configuration file provided by "Protobuf"These R packages require native OS shared libraries—GDAL, GEOS, PROJ, and udunits2—at both compile time (staging) and load time (runtime). These libraries are not present by default on the minimal cflinuxfs4 stack.
To resolve this, you must provide the required native libraries using the apt-buildpack as part of a multi-buildpack deployment. This allows you to inject the necessary Ubuntu packages into the application container before the R buildpack runs.
Implementation Steps:
1. Create an apt.yml file: In your application's root directory (the same directory as your manifest.yml or r.yml), create a file named apt.yml and list the required development libraries:
---
packages:
- libgdal-dev
- libgeos-dev
- libproj-dev
- libudunits2-dev
2. Configure Multi-Buildpacks: Update your application manifest.yml to use both the apt_buildpack and the r_buildpack. The apt_buildpack must be listed first.
---
applications:
- name: your-r-app
stack: cflinuxfs4
buildpacks:
- apt_buildpack
- r_buildpack
3. Redeploy the Application: Push the application again using the Cloud Foundry CLI:
cf push
Support Note:
References: