"Error in cairoFT() : object 'C_cairoFT' not found" & "Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error)"

Description of issue -
This problem has been driving me nuts for a while now. Whenever I try to plot something in either R or RStudio I get an error message - in R I get "Error in cairoFT() : object 'C_cairoFT' not found" and in RStudio I get "Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error)". Any help would be greatly appreciated.

R Commands

plot(mtcars)
sessionInfo()
R.Version()
options("device")
capabilities()

Output from R:

plot(mtcars)
Error in cairoFT() : object 'C_cairoFT' not found

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3
Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3

R.Version()
$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] "4"
$minor
[1] "0.3"
$year
[1] "2020"
$month
[1] "10"
day [1] "10" svn rev
[1] "79318"
$language
[1] "R"
$version.string
[1] "R version 4.0.3 (2020-10-10)"
$nickname
[1] "Bunny-Wunnies Freak Out"

options("device")
$device
function (display = "", width, height, pointsize, gamma, bg,
canvas, fonts, family, xpos, ypos, title, type, antialias,
symbolfamily)
{
if (display != "XImage") {
check <- Sys.getenv("R_CHECK_SCREEN_DEVICE", "")
msg <- "screen devices should not be used in examples etc"
if (identical(check, "stop"))
stop(msg, domain = NA)
else if (identical(check, "warn"))
warning(msg, immediate. = TRUE, noBreaks. = TRUE,
domain = NA)
}
if (display == "" && .Platform$GUI == "AQUA" && is.na(Sys.getenv("DISPLAY",
NA)))
Sys.setenv(DISPLAY = ":0")
new <- list()
if (!missing(display))
new$display <- display
if (!missing(width))
new$width <- width
if (!missing(height))
new$height <- height
if (!missing(gamma))
new$gamma <- gamma
if (!missing(pointsize))
new$pointsize <- pointsize
if (!missing(bg))
new$bg <- bg
if (!missing(canvas))
new$canvas <- canvas
if (!missing(xpos))
new$xpos <- xpos
if (!missing(ypos))
new$ypos <- ypos
if (!missing(title))
new$title <- title
if (!checkIntFormat(new$title))
stop("invalid 'title'")
if (!missing(type)) {
new$type <- match.arg(type, c("Xlib", "cairo", "nbcairo",
"dbcairo"))
if (!capabilities("cairo") && type != "Xlib")
warning("cairo-based types are not supported on this build - using "Xlib"")
}
if (!missing(family))
new$family <- family
if (!missing(fonts))
new$fonts <- fonts
if (!missing(antialias) && type != "Xlib")
new$antialias <- match.arg(antialias, aa.cairo)
if (!missing(symbolfamily))
new$symbolfamily <- symbolfamily
d <- check.options(new, name.opt = ".X11.Options", envir = .X11env)
if (d$type == "Xlib" && !missing(family)) {
fns <- X11Fonts()
if (!family %in% names(fns))
stop("unknown family for X11(type = "XLib")")
d$fonts[1] <- fns[[family]]
}
type <- if (capabilities("cairo"))
switch(d$type, cairo = 1L, nbcairo = 2L, dbcairo = 3L,
0L)
else 0L
if (display == "XImage")
type <- 0L
antialias <- match(d$antialias, aa.cairo)
if (grepl("darwin", R.version$os))
check_for_XQuartz()
.External2(C_X11, d$display, d$width, d$height, d$pointsize,
d$gamma, d$colortype, d$maxcubesize, d$bg, d$canvas,
d$fonts, NA_integer_, d$xpos, d$ypos, d$title, type,
antialias, d$family, optionSymbolFont(d$symbolfamily))
invisible()
}
<bytecode: 0x2644cd0>
<environment: namespace:grDevices>

capabilities()
jpeg png tiff tcltk X11 aqua
FALSE TRUE FALSE TRUE TRUE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE FALSE TRUE TRUE TRUE TRUE

Commands for RStudio

plot(mtcars)
sessionInfo()
RStudio.Version()
options("device")
capabilities()

Output from RStudio:

plot(mtcars)
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)

sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3 yaml_2.2.1

RStudio.Version()
$mode
[1] "desktop"
$version
[1] ‘1.4.1106’
$release_name
[1] "Tiger Daylily"

options("device")
$device
[1] "RStudioGD"

capabilities()
jpeg png tiff tcltk X11
TRUE TRUE TRUE TRUE TRUE
aqua http/ftp sockets libxml fifo
FALSE TRUE TRUE TRUE TRUE
cledit iconv NLS profmem cairo
TRUE TRUE TRUE TRUE TRUE
ICU long.double libcurl
FALSE TRUE TRUE

I've tried reinstalling both R & Rstudio, tried installing the Cairo Library. Unfortunately I'm quite a novice so I'm at a loss as to how to proceed.


Referred here from support.rstudio.com