Many popular plotting packages require cairo, a graphics device that relies on an X11 server. However, nothing that depends on X11 will work on Posit Workbench natively, including tcl/tk or cairo. These packages require access to a display, which is not available on Linux systems.
This is not unusual; most graphical programs cannot be run directly on Linux servers, and R packages that require cairo are no exception. For that reason, we recommend you do not try to run R code that relies on X11 from within Posit Workbench.
However, there is a way to run graphics remotely if you:
- Install an X11 server locally,
- Establish an SSH tunnel (
ssh -TX -R <RSP Host port>:localhost:<local port> [<user>@]<RSP Host>
) from your local machine to the RStudio Workbench host, and - Set the DISPLAY environment variable (most likely to
localhost:10.0
).
To ensure that each R Session has the correct value for the DISPLAY environment variable, you may wish to set it in the rsession-profile file (/etc/rstudio/rsession-profile
).
Please note that an X11 server and SSH tunnel will be required for each user that wishes to use X11 forwarding. Additionally, the SSH tunnel must be established by the same user account that will login to Posit Workbench.
After the the X11 server and SSH tunnel are running, you will need to restart R. With this configuration, your local X11 server will display the graphics served by the remote Posit Workbench instance. This is roughly equivalent to your setting up the SSH configuration to support X11 forwarding.
Setting up the local X11 server, configuring SSH, and setting your DISPLAY variable are outside the scope of Posit Support, but this article describes the process, and includes steps for various client operating systems:
How do I run graphical programs remotely from a Linux server?
To set the DISPLAY environment variable, see this page:
Comments