Subject: bug#28157: “r-minimal” retains no reference to “which”

From: Ricardo Wurmus <[email-masked]>
Date: Tue, 22 Aug 2017 13:02:23 +0200

Ludovic Courtès <[email-masked]> writes:

> Ricardo Wurmus <[email-masked]> skribis:
>
>> Right.  In the case of R, the environment for a package is serialized to
>> a possibly compressed data file (.Rdb) with an index (.Rdx).
>> “Sys.which” is part of the “base” package and I cannot find a plain text
>> reference to “bin/which” in the binaries for “base”.
>
> Doh!  That’s a problem.  The GC won’t detect those references either,
> which can lead to early-deletion problems.
>
>> I don’t know if we can (or should) disable compression for Rdb files.
>
> We’ll probably have to disable it.  (According to ‘file’ it’s no a
> standard compression format like gzip; maybe raw zlib without gzip
> headers?)

Here’s a patch:

>From bbacb223cbd6f1ba0ca77eda9d168e325537e3f3 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <[email-masked]>
Date: Tue, 22 Aug 2017 12:59:48 +0200
Subject: [PATCH] gnu: r-minimal: Do not compress serialized files.

* gnu/packages/statistics.scm (r-minimal)[arguments]: Replace build phase
"patch-which" with "do-not-compress-serialized-files".
[propagated-inputs]: Move "which" from here...
[inputs]: ...to here.
---
 gnu/packages/statistics.scm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/statistics.scm b/gnu/packages/statistics.scm
index dc7491acd..676752e03 100644
--- a/gnu/packages/statistics.scm
+++ b/gnu/packages/statistics.scm
@@ -127,10 +127,10 @@ be output in text, PostScript, PDF or HTML.")
        #:phases
        (modify-phases %standard-phases
          ;; FIXME: see bug #28157.
-         (add-before 'configure 'patch-which
+         (add-before 'configure 'do-not-compress-serialized-files
            (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* "src/library/base/R/unix/system.unix.R"
-               (("@WHICH@") "which"))
+             (substitute* "src/library/base/makebasedb.R"
+               (("compress = TRUE") "compress = FALSE"))
              #t))
          (add-before 'configure 'patch-uname
            (lambda* (#:key inputs #:allow-other-keys)
@@ -250,10 +250,8 @@ be output in text, PostScript, PDF or HTML.")
        ("libxt" ,libxt)
        ("pcre" ,pcre)
        ("readline" ,readline)
+       ("which" ,which)
        ("zlib" ,zlib)))
-    ;; FIXME: By default Sys.which embeds a reference to "which", but this
-    ;; reference is not detected by Guix (see bug #28157).
-    (propagated-inputs `(("which" ,which)))
     (native-search-paths
      (list (search-path-specification
             (variable "R_LIBS_SITE")
-- 
2.14.1

I have built r-minimal with it and confirmed that “which” is retained as
a reference.  I don’t know if this causes any other problems down the
road, but I think it should not be a problem.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net