RStudio Connect Upgrade

We just upgraded Connect from v1.6.10-3 to v1.7.4.1-7 and I'm seeing the following warning in the logs.
"In grDevices::png(f) : unable to open connection to X11 display ''

This issue seems to be the same thing that was reported here for shiny server:

I also saw this old post that makes me wonder if we need pango?

With this upgrade we explicitly installed both R 3.4.4 and 3.5.1 built from source using and whereas previously only R 3.4.4 was installed via install r-base in the setup.

I looked through the documentations and didn't seem to find anything related to this error or pango but maybe I missed something in the documentation. Thoughts appreciated, thanks!

Hi! Glad to hear that you installed R from source! This is very important and useful for the long-term stability of your server.

Would you mind executing capabilities() in the R console for the version in question and sharing the output? Usually this does mean that the build from source is either (1) missing some system dependencies or (2) did not have the appropriate capabilities enabled at build time

Hi @cole.

We don't have RStudio Server, just RStudio Connect, so I don't have an R console on the Server to run that command in. Instead I published the following code in a markdown file which I think provides what you're asking for. Let me know if you need more. Thank you!

## $platform
## [1] "x86_64-pc-linux-gnu"
## $arch
## [1] "x86_64"
## $os
## [1] "linux-gnu"
## $system
## [1] "x86_64, linux-gnu"
## $status
## [1] ""
## $major
## [1] "3"
## $minor
## [1] "5.1"
## $year
## [1] "2018"
## $month
## [1] "07"
## $day
## [1] "02"
## ```
svn rev`
## [1] "74947"
## $language
## [1] "R"
## $version.string
## [1] "R version 3.5.1 (2018-07-02)"
## $nickname
## [1] "Feather Spray"
##        jpeg         png        tiff       tcltk         X11        aqua 
##       FALSE       FALSE       FALSE        TRUE       FALSE       FALSE 
##    http/ftp     sockets      libxml        fifo      cledit       iconv 
##        TRUE        TRUE        TRUE        TRUE       FALSE        TRUE 
##         NLS     profmem       cairo         ICU long.double     libcurl 
##        TRUE        TRUE       FALSE        TRUE        TRUE        TRUE

Very nice!! Thanks for that output, and clever hackery to make it happen! You can also do that on the command line, but that requires shell access to the server. To be honest, I'm partial to your solution!

In any case, the missing capabilities (FALSE) for cairo, png, and jpeg is almost certainly your problem. Is it possible to build R from source again? In particular, after the ./configure step here, this same output should be presented. You can validate that the desired capabilities are present before moving on (to allow easier iteration). There are flags you can use with ./configure to ensure these are enabled.

For clarity, the yum-builddep R or apt-get build-dep r-base commands should have installed the necessary system requirements. So it would be good to make sure that the relevant command has been executed. I believe these capabilities default to TRUE if you have the relevant system dependencies.

EDIT: I am focused on the grDevices::png function here, but it is possible that X11 will matter too... I just know X11 is often not used for apps on Connect


Hi @cole, Thanks for the quick response.

Our install is scripted and owned by dev ops so unfortunately I can't step through the installs myself.
I'm wondering if our issue potentially is that we are just running r-base with a large set of selected system dependencies (shown below). I'm wondering if I need to explicitly add a lib to fix this or if changing the r-base line to be build-dep r-base would potentially do the trick.

RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -y \
            curl \
            gdebi-core \
            r-base \
            build-essential \
            libcurl4-gnutls-dev \
            openjdk-7-*  \
            libxml2-dev \
            libssl-dev \
            texlive-full \
            libgmp10-dev \
            libgsl0-dev \
            libnetcdf-dev \
            netcdf-bin \
            libdigest-hmac-perl \
            libgmp-dev \
            libgmp3-dev \
            libgl1-mesa-dev \
            libglu1-mesa-dev \
            libglpk-dev \
            tdsodbc \
            freetds-bin \
            freetds-common \
            freetds-dev \
            odbc-postgresql \
            libtiff-dev \
            libsndfile1 \
            libsndfile1-dev \
            libtiff-dev \
            tk8.5 \
            tk8.5-dev \
            tcl8.5 \
            tcl8.5-dev \
            libgsl0-dev \
            libv8-dev \
            unixodbc \

I did also try running apt-rdepends build-depends r-base but we don't have apt-depends installed on the server (I just got access to view the server last night).

Appreciate the help!

Nice! A few changes I would recommend to that list:

  • libtiff-dev is on there twice
  • usually the -dev version installs the basic (i.e. libsndfile1-dev, tk8.5-dev, tcl8.5-dev). Ok to keep both if you don't mind the redundancy :slight_smile:
  • I would recommend avoiding r-base if possible :grimacing: There are some community threads where it does weird things to even your other source builds
  • One thing you could do is try installing apt-rdepends and getting the list of the things you should be including, or going through and trying to find these things directly (i.e. you could go to another server with the same OS that has apt-rdepends and generate the list).
  • You can also just search for this stuff with apt-cache search *png and apt-cache search *pango and apt-cache search *jpeg and apt-cache search *cairo based on whatever dependencies you are missing

Again, when you go to build R from source then, after the make command, there should be output at the bottom saying which capabilities are enabled, skipped, or disabled so you can iterate to finding what you need. It's a bit of a muddy process, to be honest, but something we are working on documenting better :slight_smile:

Hi @cole,

If I remove r-base, will I have to manually install all the dependencies for R? i.e. installing R from source will not install the needed dependencies?

I was able to install apt_rdepends, it seems like I have all the pango, cairo and jpeg packages so I'm wondering if the r-base is the main cause.

Also I will add, I found I am getting an error for a report running in production. I tried install.packages("Cairo") which gave me a slew of other errors.

06/03 16:19:22.463

Error: No Cairo or bitmap device is available. Such a graphics device is required to convert sizes correctly in ggplotly().

06/03 16:19:22.463

06/03 16:19:22.463

You have two options:

06/03 16:19:22.463

(1) install.packages('Cairo')

06/03 16:19:22.463

(2) compile R to use a bitmap device (png or jpeg)

After working several angles I finally stumbled upon this article.

I ran apt-get install r-cran-cairo on the server, added library(Cairo) to my Rmarkdown and redeployed to connect and they ran without error.

I did compile the list of ~151 libraries that would be needed to install without r-base, so maybe we will get there in the future but for now I will accept this solution.

Thank you so much @cole for the help and prompt responses, greatly appreciated!

Glad to hear you found a solution! Sorry to hear about the slogging! :grimacing:

As I mentioned before, this is an area we are really hoping to make improvements so that managing R installation is a bit easier in corporate environments. Definitely let us know if we can help with anything else!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.