Plotting / Cairo DLL Errors (RStudio Server, Ubuntu 18.04)

My data scientists cannot produce graphics with R Studio Server.

I've installed R and RStudio via shell scripts on two Azure VMs running Ubuntu 18.04. One VM is in our production environment and the other is development. The production VM cannot produce plots.

I've checked the dependencies on both servers and they seem identical, so I'm not sure why one server would work and not the other. I'm guessing RStudio is

  1. not aware of the dependencies that have been installed on the server,
  2. does not have privileges to them, and/or
  3. had an error with the installation I did not catch.

Warnings / Errors with plot(c(1,1,3,4),c(30,25,21,18)):

1: In grSoftVersion() :
  unable to load shared object '/opt/R/4.0.5/lib/R/modules//R_X11.so':
  /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined symbol: FT_Get_Var_Blend_Coordinates
2: In cairoVersion() :
  unable to load shared object '/opt/R/4.0.5/lib/R/library/grDevices/libs//cairo.so':
  /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0: undefined symbol: FT_Get_Var_Blend_Coordinates
3: In grDevices:::png("/tmp/RtmpEKqjxu/92f8db82f6ca4b388c1ceefa2dccb538.png",  ... :
  failed to load cairo DLL

(Error message 3 is repeated about 47 more times with different file names with the PNG extension).

Various RStudio Settings:

> .Platform$GUI
[1] "RStudio"
> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua    http/ftp     sockets      libxml        fifo 
       TRUE        TRUE        TRUE        TRUE       FALSE       FALSE        TRUE        TRUE        TRUE        TRUE 
     cledit       iconv         NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8   
 [6] LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C        
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

loaded via a namespace (and not attached):
 [1] bit_4.0.4       compiler_4.0.5  ellipsis_0.3.2  hms_1.1.1       DBI_1.1.1       tools_4.0.5     Rcpp_1.0.7     
 [8] bit64_4.0.5     vctrs_0.3.8     blob_1.2.2      lifecycle_1.0.1 pkgconfig_2.0.3 rlang_0.4.11    renv_0.14.0    
[15] RPostgres_1.4.1
> grSoftVersion() 
  cairo cairoFT   pango  libpng    jpeg libtiff 
     ""      ""      ""      ""      ""      ""

System Dependency Check:

sudo apt list --installed | grep 'cairo\|libpng\|pango\|jpeg\|libtiff'
gir1.2-pango-1.0/bionic-updates,bionic-security,now 1.40.14-1ubuntu0.1 amd64 [installed,automatic]
libcairo-gobject2/bionic-updates,now 1.15.10-2ubuntu0.1 amd64 [installed,automatic]
libcairo-perl/bionic,now 1.106-2build2 amd64 [installed,automatic]
libcairo-script-interpreter2/bionic-updates,now 1.15.10-2ubuntu0.1 amd64 [installed,auto-removable]
libcairo2/bionic-updates,now 1.15.10-2ubuntu0.1 amd64 [installed,automatic]
libjpeg-dev/bionic,now 8c-2ubuntu8 amd64 [installed]
libjpeg-turbo8/bionic-updates,bionic-security,now 1.5.2-0ubuntu5.18.04.4 amd64 [installed,automatic]
libjpeg-turbo8-dev/bionic-updates,bionic-security,now 1.5.2-0ubuntu5.18.04.4 amd64 [installed,automatic]
libjpeg8/bionic,now 8c-2ubuntu8 amd64 [installed,automatic]
libjpeg8-dev/bionic,now 8c-2ubuntu8 amd64 [installed]
libpango-1.0-0/bionic-updates,bionic-security,now 1.40.14-1ubuntu0.1 amd64 [installed,automatic]
libpango-perl/bionic,now 1.227-2build1 amd64 [installed,automatic]
libpangocairo-1.0-0/bionic-updates,bionic-security,now 1.40.14-1ubuntu0.1 amd64 [installed,automatic]
libpangoft2-1.0-0/bionic-updates,bionic-security,now 1.40.14-1ubuntu0.1 amd64 [installed,automatic]
libpangoxft-1.0-0/bionic-updates,bionic-security,now 1.40.14-1ubuntu0.1 amd64 [installed,automatic]
libpng-dev/bionic-updates,bionic-security,now 1.6.34-1ubuntu0.18.04.2 amd64 [installed]
libpng-tools/bionic-updates,bionic-security,now 1.6.34-1ubuntu0.18.04.2 amd64 [installed,automatic]
libpng16-16/bionic-updates,bionic-security,now 1.6.34-1ubuntu0.18.04.2 amd64 [installed,automatic]
libtiff5/bionic-updates,bionic-security,now 4.0.9-5ubuntu0.4 amd64 [installed,automatic]
r-cran-cairodevice/bionic,now 2.24-2build1 amd64 [installed]

Shell Script to Install R / RStudio:

###########################################################################
############################ Software Versions ############################
###########################################################################

RSP_VERSION=1.3.1093
R_VERSION=4.0.5
RENV_VERSION=0.14.0


###########################################################################
########################## Applications: R Studio #########################
###########################################################################

sudo apt-get update
DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y curl gdebi libapparmor1 libc6 libclang-dev libcurl4-gnutls-dev libedit2 libpq-dev libssl1.0.0 libssl-dev libuser libuser1-dev psmisc rrdtool sudo wget
sudo apt-get install -y gdebi-core
cd /download 
curl -O https://download2.rstudio.org/server/bionic/amd64/rstudio-server-${RSP_VERSION}-amd64.deb
sudo gdebi -n rstudio-server-${RSP_VERSION}-amd64.deb


###########################################################################
############################# Applications: R #############################
###########################################################################

# Need to review this source: https://techcommunity.microsoft.com/t5/educator-developer-blog/hosting-rserver-and-rstudio-on-azure/ba-p/744389
# Maybe this too: https://docs.rstudio.com/resources/install-r/
curl -O https://cdn.rstudio.com/r/ubuntu-1804/pkgs/r-${R_VERSION}_1_amd64.deb 
sudo apt-get update
DEBIAN_FRONTEND=noninteractive 
sudo gdebi --non-interactive r-${R_VERSION}_1_amd64.deb

# Add symbolic links to make calling R and Rscript easier
sudo ln -sf /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
sudo ln -sf /opt/R/${R_VERSION}/bin/R /usr/local/bin/r
sudo ln -sf /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript

This support article may shed light.

Thank you. I had reviewed this article, but as I never had X11 running on the development server I assumed it didn't apply. I think the clue is in

libharfbuzz.so.0: undefined symbol: FT_Get_Var_Blend_Coordinate

It seems there's either an unsupported version of freetype floating around (maybe it came with Azure's Ubuntu 18.04 image) or the installation order of system dependencies matters a lot (i.e., there's some circular referencing).

I'm playing around with both ideas to narrow down the culprit...

The thing that I noted in the article is that the X11/Cairo resource is geared to an interactive environment, so, I guess, there is no appropriate stdout to pipe to in a server without a graphic display client.

This topic was automatically closed 21 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.