Running viridis as sudo in Ubuntu 20.04

I'm using Ubuntu 20.04, which was probably a bad idea but I was trying to fix something in 18.04 and went forward and now wish I hadn't. I really don't want to reinstall everything if I can help it.

My problem is with viridis, but I wonder if it's a general problem too. I have a few versions of R installed (because I'm using Connect on a server) so I'm being careful with which I launch. I launch R 3.6 as myself like this:

/opt/R/3.6.3/bin/R

Then I get the following:

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(viridis)
Loading required package: viridisLite
>
> library(viridis)
>
> x <- y <- seq(-8*pi, 8*pi, len = 40)
> r <- sqrt(outer(x^2, y^2, "+"))
> filled.contour(cos(r^2)*exp(-r/(2*pi)),
+                axes=FALSE,
+                color.palette=viridis,
+                asp=1)
Error in (function (file = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf",  :
  cannot open file 'Rplots.pdf'

This is the expected behaviour, this is working it just can't print because I'm on a terminal shelled into the server. Here is the sessionInfo

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

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

other attached packages:
[1] viridis_0.5.1     viridisLite_0.3.0

loaded via a namespace (and not attached):
 [1] dplyr_1.0.0      crayon_1.3.4     grid_3.6.3       R6_2.4.1
 [5] lifecycle_0.2.0  gtable_0.3.0     magrittr_1.5     scales_1.1.1
 [9] ggplot2_3.3.1    pillar_1.4.4     rlang_0.4.6      generics_0.0.2
[13] vctrs_0.3.1      ellipsis_0.3.1   glue_1.4.1       purrr_0.3.4
[17] munsell_0.5.0    compiler_3.6.3   pkgconfig_2.0.3  colorspace_1.4-1
[21] tidyselect_1.1.0 gridExtra_2.3    tibble_3.0.1

BUT if I launch R like this:

sudo /opt/R/3.6.3/bin/R

Then I get this:

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(viridis)
Loading required package: viridisLite
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

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

other attached packages:
[1] viridis_0.5.1     viridisLite_0.3.0

loaded via a namespace (and not attached):
 [1] dplyr_1.0.0      crayon_1.3.4     grid_3.6.3       R6_2.4.1
 [5] lifecycle_0.2.0  gtable_0.3.0     magrittr_1.5     scales_1.1.1
 [9] ggplot2_3.3.1    pillar_1.4.4     rlang_0.4.6      generics_0.0.2
[13] vctrs_0.3.1      ellipsis_0.3.1   glue_1.4.1       purrr_0.3.4
[17] munsell_0.5.0    compiler_3.6.3   pkgconfig_2.0.3  colorspace_1.4-1
[21] tidyselect_1.1.0 gridExtra_2.3    tibble_3.0.1

Now running the same command just hangs:

> x <- y <- seq(-8*pi, 8*pi, len = 40)
> r <- sqrt(outer(x^2, y^2, "+"))
> filled.contour(cos(r^2)*exp(-r/(2*pi)),
+                axes=FALSE,
+                color.palette=viridis,
+                asp=1)

I know this doesn't matter in itself but I think this is the problem I'm having with Connect. Applications with viridis are not working and I've set Connect to use the site wide viridis install- which as you can see works when I'm running R as myself but not when it's run as sudo. So I'm guessing that because Connect is not running as me it doesn't work.

The really weird thing is that the stringi package seems to be involved somewhere. If I remove that from my package library the command hangs just as it does with sudo, even though it never asks for stringi.

I'm quite baffled and I really think I'm going to have to tear it down and start again which is going to take me a week.

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