Subject: bug#50483: [R] Package r-shiny: Shiny server logic inactive

From: Todor Kondić <[email-masked]>
Date: Thu, 09 Sep 2021 12:35:40 +0000

Hi,

I started having issues with R Shiny applications with newer Guix distro commits. I have a feeling that this is an issue arising from `r-shiny` dependency clashes and that (some) of those dependencies should be either downgraded, or upgraded.

The problem is that the server logic of a shiny application is never active. The web application UI is displayed correctly, even initialised correctly, but the logic behind it does not work.

Take, for example, a classic shiny demo app [1]. The control with the number of observations is displayed, but the plot depending on it never shows up. This behavior exists on recent Guix builds [2].

However, on one older build from a few months ago [3], the application runs fine.

You will find below the manifest[4] for creating the environment where Shiny programs malfunction and the command[5] to create the environment with the manifest.

By the way, for those of you who are R savvy, comparing sessionInfo() between the running and non-running version did uncover few version changes. I have not yet delved deeper in
what is the root cause, but I think I noticed that this is not
the difference in versions of R itself.

Lastly, if this is really a universal (ie I am not the
only one seeing this), then this is a significant problem
for a lot of people doing scientific computing on Guix.

sessionInfo() for working version:

R version 4.1.0 (2021-05-18)
Platform: x86_64-unknown-linux-gnu (64-bit)

Matrix products: default
BLAS/LAPACK: /gnu/store/bs9pl1f805ins80xaf4s3n35a0x2lyq3-openblas-0.3.9/lib/libopenblasp-r0.3.9.so

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] shiny_1.6.0

loaded via a namespace (and not attached):
 [1] compiler_4.1.0    fastmap_1.1.0     ellipsis_0.3.2    magrittr_2.0.1
 [5] R6_2.5.0          promises_1.2.0.1  later_1.2.0       tools_4.1.0
 [9] htmltools_0.5.1.1 Rcpp_1.0.6        digest_0.6.27     xtable_1.8-4
[13] httpuv_1.6.1      lifecycle_1.0.0   mime_0.10         rlang_0.4.11

sessionInfo for the non-working version:
R version 4.1.1 (2021-08-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

Matrix products: default
BLAS/LAPACK: /gnu/store/bs9pl1f805ins80xaf4s3n35a0x2lyq3-openblas-0.3.9/lib/libopenblasp-r0.3.9.so

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8
 [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8
 [7] LC_PAPER=en_GB.utf8       LC_NAME=C
 [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] shiny_1.6.0

loaded via a namespace (and not attached):
 [1] compiler_4.1.1    fastmap_1.1.0     ellipsis_0.3.2    magrittr_2.0.1
 [5] R6_2.5.1          promises_1.2.0.1  later_1.3.0       htmltools_0.5.1.1
 [9] tools_4.1.1       Rcpp_1.0.7        digest_0.6.27     xtable_1.8-4
[13] httpuv_1.6.2      lifecycle_1.0.0   mime_0.11         rlang_0.4.11

Reproducible-ish demo:

1. runme.R
```r
library(ggplot2)
library(shiny)

app <- shinyApp(
    ui = bootstrapPage(
        numericInput('n', 'Number of obs', 100),
        plotOutput('plot')
    ),
    server = function(input, output) {
        output$plot <- renderPlot({ hist(runif(input$n)) })
    }
)

# Will show a warning, because the browser is not in the manifest, but
# it it will serve the application on a listed port, which means it
# can be accessed by a browser external to the environment.
options(browser="itdoesnotmatter")
shiny::runApp(app)

```

2. for example, guix version: 816d52ba93d262548f5e1139ff6051887f13dd0d

3. for example, guix version:
29745d23b87529275a677ee7962b0405594e84db

4. Manifest for creating the environment:

```scheme
(use-modules (guix packages)
	     (guix inferior)
	     (guix channels)
	     (guix profiles)
	     (guix utils)
	     (guix build-system gnu)
	     (gnu packages)
	     (gnu packages commencement)
	     (gnu packages gcc)
             (srfi srfi-1)
	     (ice-9 pretty-print))

(define base-specs '("git"
		     "rsync"
                     "make"))

(define font-specs '("unicode-emoji"
		     "fontconfig"
		     "font-dejavu"
		     "font-gnu-freefont"
		     "font-terminus"
		     "font-liberation"
		     "font-inconsolata"
		     "font-gnu-unifont"
		     "font-public-sans"
		     "font-misc-misc"
		     "font-awesome"
		     "font-hack"
		     "font-iosevka"
		     "font-iosevka-term"
		     "font-iosevka-term-slab"
		     "font-iosevka-slab"
		     "font-iosevka-etoile"
		     "font-iosevka-aile"
		     "font-google-noto"))

(define r-specs '("r"
		  "r-curl"
		  "r-ellipsis"
		  "r-future"
		  "r-rmarkdown"
		  "r-knitr"
		  "r-rcolorbrewer"
		  "r-data-table"
		  "r-shiny"
		  "r-cowplot"
		  "r-pander"
		  "r-rstatix"
                  "r-r-utils"))

(define texlive-specs '("texlive"))

(define misc-specs '("sshpass"
		     "xdg-utils"
		     "xdg-user-dirs"
		     "pango"
		     "libxft"
		     "cairo"
		     "gnupg"
                     "openssl"))

(define java-specs '(;"maven"
		     "openjdk:out"
		     "openjdk:jdk"))

(define perl-specs '("perl-yaml-libyaml"))
(define gnu-toolchain-specs '("gcc-toolchain"))

(define specs `(,@base-specs
		,@font-specs
		,@perl-specs
		,@r-specs
		,@java-specs
		,@gnu-toolchain-specs
		,@misc-specs
                ,@texlive-specs))

(define dev-channels

  (list (channel
	 ;; This is custom Environmental Cheminformatics LCSB channel.
        (name 'eci-addons)
        (url "https://git.sr.ht/~condor/eci-guix")
	(branch "master")
        (introduction
	 (make-channel-introduction
	  "6642600059913e86657242ba369d752c0af2bff5"
	  (openpgp-fingerprint
	   "EDC3 9790 A06D 5F72 41D9  70F9 BBEF E71B 7A28 3C6F"))))
       (channel
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
         (commit "29745d23b87529275a677ee7962b0405594e84db"))))

(define inferior (inferior-for-channels dev-channels))

(define inferior-mnf-entry-list
  (map (lambda (spec)
	 (let*
	     ((spkgout (string-split spec #\:))
	      (spkg (car spkgout))
	      (rest (cdr spkgout))
	      (sout (if (null? rest)
			"out"
			(car rest)))
	      (pkg (first
		    (lookup-inferior-packages inferior spkg))))
	   (display (format #f "Commiting ~a to the inferior manifest list.\n" spkg))
	   (inferior-package->manifest-entry pkg sout)))
       specs))

(display "Done building inferior list.\n")

(define default-manifest
  (make-manifest '()))

(define all-manifest-entries inferior-mnf-entry-list)

(define manifest (make-manifest all-manifest-entries))
;;; For the fresh version
;;; (define manifest (specifications->manifest specs))

(display "Ready to go.") (newline)

manifest

```

5. Shell command to invoke the environment
```shell
guix environment -m ~/.local/my-scripts/r-manif.scm -c4 --pure -- R
```

After the command is run, just `source('runme.R')`.