'Unable to load fonts on Ubuntu

Using R version 4.1.2 on Ubuntu 20.04, I run hist(10). The error says

X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 2 at size 14 could not be loaded

I find two things on google. This thread I can't understand, and this thread suggests I build R differently. I did recently build R from source, without the cairo flag recommended by the Bio-Deago github thread, but I have now replaced it with a binary from Rstudio, and the problem persists. Any suggestions? Thanks!

EDIT: the problem only occurs in Rstudio, not when I run R through a terminal.



Solution 1:[1]

R gets installed to different places depending on whether you install from source or as a binary: see this, which says:

For versions of R installed by system package managers (e.g. r-base on Debian or Ubuntu) this will be /usr/bin/R. For versions of R installed from source this will typically (but not always) be /usr/local/bin/R.

Rstudio looks first at which R, which in this case is the version from source. I deleted the source version (target of symlink at which R). Then when I ran R in a terminal, said R is not installed. Then, I followed the Rstudio binary install instructions mentioned in the question. I followed them from the beginning even though I had already installed an Rstudio binary. Now I can run hist(10) and get a plot as expected.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eric_kernfeld