Subject: bug#28034: elixir build fails

From: nee <[email-masked]>
Date: Sun, 3 Dec 2017 15:48:56 +0100

Hello, thank you for the fast and detailed reply.
I made two patches that upgrade erlang and elixir and disable the
failing tests in elixir, and got it to build again.

I sometimes get this undeterministic compile error (see the attached
log). It's always the same error, but it doesn't appear every time, so I
can get a passing build running:

`until ./pre-inst-env guix build elixir; do sleep 1; done`

I don't think that it is related to the version upgrade because I also
got this with the old versions when I first tried to build it today.

While this still not good, it is at least an improvement over the
current state where the package will fail to install in 100% of cases.
From fda40d470fab9ceb58c0e42e59db766eaf840730 Mon Sep 17 00:00:00 2001
From: nee <[email-masked]>
Date: Sun, 3 Dec 2017 15:37:28 +0100
Subject: [PATCH 1/2] gnu: erlang: Update to 20.1.

* gnu/packages/erlang.scm (erlang): Update to 20.1.
---
 gnu/packages/erlang.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/erlang.scm b/gnu/packages/erlang.scm
index 1a575a0fd..770ed715b 100644
--- a/gnu/packages/erlang.scm
+++ b/gnu/packages/erlang.scm
@@ -35,7 +35,7 @@
 (define-public erlang
   (package
     (name "erlang")
-    (version "20.0")
+    (version "20.1")
     (source (origin
               (method url-fetch)
               ;; The tarball from http://erlang.org/download contains many
@@ -46,7 +46,7 @@
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "11xp6vv1v7iay9dg1xc6xm7izfsanbn5pgwp96ba0j1fmlkhjw92"))
+                "0r4g8ag7nlpw06y4c39fgcyccykj2sbyhv5jgp4qmrjci2ydgns8"))
               (patches (search-patches "erlang-man-path.patch"))))
     (build-system gnu-build-system)
     (native-inputs
@@ -62,7 +62,7 @@
                                version ".tar.gz"))
            (sha256
             (base32
-             "1k25p37w1l1j20qd8rga4j4q7s7r0rbsi02x3xwzhw51jhm59wdp"))))))
+             "0ikvdpn4z7az6szg176l1r2yxhgs3msa3wgb3gmy45jkz0pzik05"))))))
     (inputs
      `(("ncurses" ,ncurses)
        ("openssl" ,openssl)
-- 
2.14.1

From 3fe3e538a098eb1c0e8fee4d99231c720282db53 Mon Sep 17 00:00:00 2001
From: nee <[email-masked]>
Date: Sun, 3 Dec 2017 15:39:40 +0100
Subject: [PATCH 2/2] gnu: elixir: Update to 1.5.2 and disable failing tests.

* gnu/packages/elixir.scm (elixir)[origin]: Update to 1.5.2.
[arguments]: Patch the shebang of mix. Disable failing tests.
---
 gnu/packages/elixir.scm | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
index 7425b49a4..c630b635e 100644
--- a/gnu/packages/elixir.scm
+++ b/gnu/packages/elixir.scm
@@ -30,7 +30,7 @@
 (define-public elixir
   (package
     (name "elixir")
-    (version "1.4.2")
+    (version "1.5.2")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://github.com/elixir-lang/elixir"
@@ -38,7 +38,7 @@
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "0gsmgx4h6rvxilcbsx2z6yirm6g2g5bsxdvr0608ng4bsv22wknb"))
+                "0v7z0avs3gir7qdfgysfw88l3z9p5f7p7pjnrnsz5gmmsflvf5vk"))
               ;; FIXME: 27 tests (out of 4K) had to be disabled as
               ;; they fail in the build environment.  Common failures
               ;; are:
@@ -55,14 +55,18 @@
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'replace-paths
-           (lambda* (#:key inputs #:allow-other-keys)
-             (substitute* '("lib/elixir/lib/system.ex"
-                            "lib/mix/lib/mix/scm/git.ex")
-               (("(cmd\\(['\"])git" _ prefix)
-                (string-append prefix (which "git"))))
-             (substitute* "bin/elixir"
-               (("ERL_EXEC=\"erl\"")
-                (string-append "ERL_EXEC=" (which "erl"))))
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* '("lib/elixir/lib/system.ex"
+                              "lib/mix/lib/mix/scm/git.ex")
+                 (("(cmd\\(['\"])git" _ prefix)
+                  (string-append prefix (which "git"))))
+               (substitute* "bin/elixir"
+                 (("ERL_EXEC=\"erl\"")
+                  (string-append "ERL_EXEC=" (which "erl"))))
+               (substitute* "bin/mix"
+                 (("#!/usr/bin/env elixir")
+                  (string-append "#!" out "/bin/elixir"))))
              #t))
          (add-after 'unpack 'fix-or-disable-tests
            (lambda* (#:key inputs #:allow-other-keys)
@@ -75,6 +79,15 @@
 
              ;; FIXME: Mix.Shell.cmd() always fails with error code 130.
              (delete-file "lib/mix/test/mix/shell_test.exs")
+
+             ;; FIXME:
+             ;; disabled failing impure tests to make it build again.
+             ;; related discussion: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28034#14
+             (delete-file "lib/elixir/test/elixir/kernel/cli_test.exs")
+             (delete-file "lib/elixir/test/elixir/kernel/dialyzer_test.exs")
+             (delete-file "lib/iex/test/iex/helpers_test.exs")
+             (delete-file "lib/ex_unit/test/ex_unit/capture_io_test.exs")
+
              #t))
          (add-before 'build 'make-current
            ;; The Elixir compiler checks whether or not to compile files by
-- 
2.14.1