Repository: spack/spack

Issue:
glib build error when path to the python interpreter longer than 127 characters
```
$ spack install glib %gcc@6.3.0
==> bzip2 is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/bzip2-1.0.6-o7ju7zmwqsgjf5gkorgim2mlwigf22o3
==> pkgconf is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/pkgconf-1.4.0-s7hphkxos7bpn4tuxewhlck2pt7zbdsv
==> xz is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/xz-5.2.3-ykab3p2bvexcc2jdvwnhp6lbrvqcksr6
==> zlib is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/zlib-1.2.11-stzevb2ziukxl7rusqgbtmgwhtwc3f24
==> libxml2 is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/libxml2-2.9.4-5y42e44iydk67ej5pjwibk5iz2fxu6yu
==> ncurses is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/ncurses-6.0-yv3aqv5yim7lbxuybpvvpvmoxglvuwbt
==> tar is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/tar-1.29-yto4kk4m2qwyk6qdcrbnjx5tbsayohpo
==> gettext is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/gettext-0.19.8.1-dta27tq2grkfpkxywmxejpq35yjqki5z
==> libffi is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/libffi-3.2.1-3ju6xlgrjvdlppvp2wdrtecfm4wkrhrr
==> pcre is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/pcre-8.41-7yvwappbc6dx4ahldckkzebj3upbjig4
==> readline is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/readline-7.0-p3foijquiexltblnir4eqwwyipymr3sq
==> gdbm is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/gdbm-1.14.1-2ufuqekczzr2edg6dxsio57j4sovn5bq
==> perl is already installed in /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-6.3.0/perl-5.24.1-frz2vujimmvu3e3k46uufpf54owbken5
==> Installing glib
==> Using cached archive: /cfs/fs2/home/users/aryczkowski/tmp/spack/var/spack/cache/glib/glib-2.55.1.tar.xz
==> Staging archive: /cfs/fs2/home/users/aryczkowski/tmp/spack/var/spack/stage/glib-2.55.1-pzwv4fqrkohxlvvpfplall4umdd2ddah/glib-2.55.1.tar.xz
==> Created stage in /cfs/fs2/home/users/aryczkowski/tmp/spack/var/spack/stage/glib-2.55.1-pzwv4fqrkohxlvvpfplall4umdd2ddah
==> Applied patch no-Werror=format-security.patch
==> Building glib [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j20'

6 errors found in build log:
     [ ... ]
     1091  make[2]: Entering directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests'
     1092  make  all-recursive
     1093  make[3]: Entering directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests'
     1094  Making all in gobject
     1095  make[4]: Entering directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests/gobject'
     1096    GEN      stamp-testmarshal.h
  >> 1097  /usr/bin/env: /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-7.2.0/python-3.6.3-24qbbd4ylmql: No such file or directory
  >> 1098  make[4]: *** [stamp-testmarshal.h] Error 127
     1099  make[4]: Leaving directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests/gobject'
  >> 1100  make[3]: *** [all-recursive] Error 1
     1101  make[3]: Leaving directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests'
  >> 1102  make[2]: *** [all] Error 2
     1103  make[2]: Leaving directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1/tests'
  >> 1104  make[1]: *** [all-recursive] Error 1
     1105  make[1]: Leaving directory `/ram/tmp/aryczkowski/spack-stage/spack-stage-XuKPF6/glib-2.55.1'
  >> 1106  make: *** [all] Error 2

See build log for details:
  /cfs/fs2/home/users/aryczkowski/tmp/spack/var/spack/stage/glib-2.55.1-pzwv4fqrkohxlvvpfplall4umdd2ddah/glib-2.55.1/spack-build.out
```

```
$ uname -r
2.6.32-573.12.1.el6.x86_64

$ lsb_release -a
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	Scientific
Description:	Scientific Linux release 6.4 (Carbon)
Release:	6.4
Codename:	Carbon
```

I think the key line is  >> 1097  /usr/bin/env: /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-7.2.0/python-3.6.3-24qbbd4ylmql: No such file or directory`. The python is in the directory `/cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-7.2.0/python-3.6.3-24qbbd4ylmqltmd2ggi43t7txghmi6u7`. Take notice, that the path got abbreviated on the 127th character.

```
$ ll /cfs/fs2/home/users/aryczkowski/tmp/spack/opt/spack/linux-scientific6-x86_64/gcc-7.2.0
total 200
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 20:12 autoconf-2.69-rdndt6cclcqvwxneri55yu3pvytpe2jk
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 20:12 automake-1.15.1-jhtcij2wgt4z4eiyw5rckr76umbky7xt
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 21:49 bison-3.0.4-yk4djqdrka2an6343z23riex5c2ejddb
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:56 bzip2-1.0.6-s6eeb6gmdby3qkffsd6eicbh2ehv3g74
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 21:43 cmake-3.10.0-h5elhehjbr5uhg3pjss4i756emf4kwjn
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 22:09 curl-7.56.0-73c3xiu7aw5mb7q2oo4qyc36lpbztodh
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:33 expat-2.2.2-qhosju4x7oy43sh4vneycunwwtjjczpe
drwxr-xr-x 9 aryczkowski windows 4096 Jan 10 20:55 gcc-6.3.0-shm3rnsxt4qsrun5awoljaml5kzprg5s
drwxr-xr-x 9 aryczkowski windows 4096 Jan 10 21:30 gcc-7.2.0-nb6gxbpybc4pueuozwmuly7yjsaeu6fu
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:09 gdbm-1.14.1-crfeq75frsblmljuqvw5xoyrwrpximgv
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:40 gettext-0.19.8.1-fcpwn6p3mp4gszuqedv4n3wwf6vlhtv5
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:44 git-2.15.1-otuo4xlziqhoa4cva4tvu2kq245e44vz
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 20:14 gmp-6.1.2-4esi2seqljkh4lob4otodl7avzj75qvo
drwxr-xr-x 7 aryczkowski windows 4096 Jan 11 08:46 hdf5-1.10.1-doupv46qgmcbt2i6oy67hvbkomvlizmo
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 22:09 htop-2.0.2-ltc7rhuaq55xp3exiqeqzwlzww6i7nsb
drwxr-xr-x 8 aryczkowski windows 4096 Jan 10 23:22 hwloc-1.11.8-lso3wzxqxzbydaplazbdvwmvflqbzcdc
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 20:14 isl-0.18-hf7cihjupvo7iuwklx3662xy7xrlapuu
drwxr-xr-x 9 aryczkowski windows 4096 Jan 10 23:11 jdk-8u141-b15-ilpdoqmgoqqafp7s6z72up7knmfnrxz3
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 21:57 jq-1.5-cf4ahwvprjqsau32iddrukjknrjfwxkc
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 23:33 libbsd-0.8.6-3bijgypjdhw5iv5d7yxuzshrbbce3ejd
drwxr-xr-x 6 aryczkowski windows 4096 Jan 11 12:16 libffi-3.2.1-j56fysmicppmzokhezbb4xkleurqdovs
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:42 libiconv-1.15-zrnwrehql7c3cy2dbrvxzsuwnqbnr6gg
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 23:20 libpciaccess-0.13.5-msya733y3ncmsimzzmyvoyy4zcy3gk4r
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 20:06 libsigsegv-2.11-53a6bu2o574nz2omacj6uryrnh5s6gjx
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:13 libtool-2.4.6-owxfhwiz3n672ek7u7mxse66yvs6xc4w
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:21 libxml2-2.9.4-zgzkj6uuehc4qi6fnnabyklrcpw2wdog
drwxr-xr-x 5 aryczkowski windows 4096 Jan 10 20:07 m4-1.4.18-y3xotrrqkylbgylkk3ds4tzvdkyy3gbs
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 20:15 mpc-1.0.3-kairriuzx5v4fl7mjkhiqeipsoq7vbqx
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 20:15 mpfr-3.1.5-xqtt3lcq4gzrrohdwbdnhsrzlb6f34ty
drwxr-xr-x 7 aryczkowski windows 4096 Jan 11 08:38 mpich-3.2-zvbqdk4n5rffuhglagqkoat5zujffnhw
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:09 ncurses-6.0-3ipa7h65l5q3hztaio7dddz4umrrwd4w
drwxr-xr-x 7 aryczkowski windows 4096 Jan 11 08:46 netcdf-4.4.1.1-yxflk7rusezhmqvv3hf63camdf2whwny
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 22:06 node-js-8.9.1-l4iepzbvp5oxx226l2zjyoaek56cacdh
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 22:07 npm-3.10.9-bx4xf2jznnbh5zqhbkapkjxawut7oau2
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 21:57 oniguruma-6.1.3-vksbhpflu42h64sqsz4ezgfrqsvatfmp
drwxr-xr-x 8 aryczkowski windows 4096 Jan 11 08:43 openmpi-3.0.0-egecisgn5ec7et2xwxch7ufpwhhjnbk4
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:59 openssl-1.0.2n-xbc6fi4fhzwvhoddsk5btp7hx65nlpbp
drwxr-xr-x 7 aryczkowski windows 4096 Jan 11 12:36 parallel-netcdf-1.9.0-ttntblj6kpj7qg4ieizihoq36ixch73f
drwxr-xr-x 7 aryczkowski windows 4096 Jan 11 12:17 pcre-8.41-qmjppvwgapfl2w5bzmg6gifnrzfqo65u
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:43 pcre-8.41-ukro5tkoas4rlykkqrz34a4f5fnitjcf
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 20:12 perl-5.24.1-4elhnequ7c5r3mnrpz7tkj2eccah36rw
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:07 pkgconf-1.4.0-advvyyjuzm3qjlixhtcxov52d25ktvia
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 22:00 python-2.7.14-skorlfkofgo5uviqtsl4lvmdkpfpnc7t
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 21:02 python-3.6.3-24qbbd4ylmqltmd2ggi43t7txghmi6u7
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 20:09 readline-7.0-qko7p7bo5hm4tbwjciohafufmpbzpgnz
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 21:00 sqlite-3.21.0-olhqkhbb4r5z67eq4wxhkz3c4ed7h6iz
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 23:35 tar-1.29-xq6wac2exegpqmf2umexvwj6a37a44aq
drwxr-xr-x 4 aryczkowski windows 4096 Jan 10 21:40 util-macros-1.19.1-yfk4nqs3ygoj37folmgjasex5rpldiab
drwxr-xr-x 7 aryczkowski windows 4096 Jan 10 23:21 xz-5.2.3-dysrzv6n2urki6g4bddexujuxviq2p6d
drwxr-xr-x 6 aryczkowski windows 4096 Jan 10 20:15 zlib-1.2.11-f3j6u6rr3i73myeous62cjj7ok3zjzlz
```


Discussion:
@hartzell has the magic touch that can fix this one. If he's too busy, check out #5910, #5834, #5632, #4839, or #3208 for what needs to be done.
Oh wait, it looks like @michaelkuhn already did this in #5204. Is it no longer working? Are you using the latest develop branch or an old release?
The Spack version

```
commit 03ff2a32aef078f7b091d0a8da1e6bb2a1491081 (HEAD -> develop, origin/develop, origin/HEAD)
Author: Adam J. Stewart <ajstewart426@gmail.com>
Date:   Thu Jan 11 16:14:26 2018 -0600

    Reduce verbosity of build tests (#6901)
```

still produces this error. Both on compute node and access node.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/glib/package.py b/var/spack/repos/builtin/packages/glib/package.py
--- a/var/spack/repos/builtin/packages/glib/package.py
+++ b/var/spack/repos/builtin/packages/glib/package.py
@@ -48,6 +48,7 @@ class Glib(AutotoolsPackage):
     depends_on('zlib')
     depends_on('gettext')
     depends_on('perl', type=('build', 'run'))
+    depends_on('python', type=('build', 'run'), when='@2.53.4:')
     depends_on('pcre+utf', when='@2.48:')
     depends_on('util-linux', when='+libmount')
 
@@ -73,10 +74,30 @@ def configure_args(self):
 
         return args
 
-    @run_before('install')
+    @run_before('configure')
+    def fix_python_path(self):
+        if not self.spec.satisfies('@2.53.4:'):
+            return
+
+        files = ['gobject/glib-genmarshal.in', 'gobject/glib-mkenums.in']
+
+        filter_file('^#!/usr/bin/env @PYTHON@',
+                    '#!/usr/bin/env python',
+                    *files)
+
+    @run_after('install')
     def filter_sbang(self):
-        # Filter sbang before install so Spack's sbang hook can fix it up
-        perl = join_path(self.spec['perl'].prefix.bin, 'perl')
-        files = ['gobject/glib-mkenums']
+        # Revert sbang, so Spack's sbang hook can fix it up (we have to do
+        # this after install because otherwise the install target will try
+        # to rebuild files as filter_file updates the timestamps)
+        if self.spec.satisfies('@2.53.4:'):
+            pattern = '^#!/usr/bin/env python'
+            repl = '#!{0}'.format(self.spec['python'].command.path)
+            files = ['glib-genmarshal', 'glib-mkenums']
+        else:
+            pattern = '^#! /usr/bin/perl'
+            repl = '#!{0}'.format(self.spec['perl'].command.path)
+            files = ['glib-mkenums']
 
-        filter_file('^#! /usr/bin/perl', '#!{0}'.format(perl), *files)
+        files = [join_path(self.prefix.bin, file) for file in files]
+        filter_file(pattern, repl, *files, backup=False)


Test patch: