Repository: spack/spack

Issue:
Installation issue: lua-luafilesystem
I have a nightly CI build that now dies while trying to do a `spack install lua-luafilesystem`.  This occurred upon the the merge of #11528 

In other words, I am seeing that `lua-luafilesystem` will not install using commit eb584d8 but will install from 8e3fd3f.

This is on CentOS 7 , gcc 8.2.0

### Steps to reproduce the issue

```
[spack]$ git checkout eb584d8
Previous HEAD position was 8e3fd3f... tty: make tty.* print exception types
HEAD is now at eb584d8... refactor: remove unused spack.stage._get_mirrors() function
[spack]$ ./bin/spack install lua-luafilesystem
...
==> lua is already installed in /home/osolberg/temp/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/lua-5.3.5-fulv52lir6poddzxeogk7rgrqglnkbon
==> Installing lua-luafilesystem
==> Searching for binary cache of lua-luafilesystem
==> Finding buildcaches in /bifx/apps/spack/mirror/build_cache
==> No binary for lua-luafilesystem found: installing from source
==> Using cached archive: /home/osolberg/temp/spack/var/spack/cache/lua-luafilesystem/lua-luafilesystem-1_7_0_2.tar.gz
==> Staging archive: /home/osolberg/temp/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-dhumhtidskeakxzmlru6qnprnpw7lthz/v1_7_0_2.tar.gz
==> Created stage in /home/osolberg/temp/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-dhumhtidskeakxzmlru6qnprnpw7lthz
==> No patches needed for lua-luafilesystem
==> Building lua-luafilesystem [Package]
==> Error: OSError: [Errno 2] No such file or directory: '/home/osolberg/temp/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-dhumhtidskeakxzmlru6qnprnpw7lthz/src'

/home/osolberg/temp/spack/lib/spack/spack/package.py:1577, in build_process:
       1574                    echo = logger.echo
       1575                    self.log()
       1576
  >>   1577                # Run post install hooks before build stage is removed.
       1578                spack.hooks.post_install(self.spec)
       1579
       1580            # Stop timer.

```

### Platform and user environment

```commandline
[spack]$ uname -a
Linux bifx1n03.bold.bio 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

[spack]$ ./bin/spack spec --install-status lua-luafilesystem
Input spec
--------------------------------
 -   lua-luafilesystem

Concretized
--------------------------------
 -   lua-luafilesystem@1_7_0_2%gcc@8.2.0 arch=linux-centos7-x86_64
[+]      ^git@2.21.0%gcc@8.2.0~tcltk arch=linux-centos7-x86_64
[+]          ^autoconf@2.69%gcc@8.2.0 arch=linux-centos7-x86_64
[+]              ^m4@1.4.18%gcc@8.2.0 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-centos7-x86_64
[+]                  ^libsigsegv@2.11%gcc@8.2.0 arch=linux-centos7-x86_64
[+]              ^perl@5.26.2%gcc@8.2.0+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-centos7-x86_64
[+]                  ^gdbm@1.18.1%gcc@8.2.0 arch=linux-centos7-x86_64
[+]                      ^readline@7.0%gcc@8.2.0 arch=linux-centos7-x86_64
[+]                          ^ncurses@6.1%gcc@8.2.0~symlinks~termlib arch=linux-centos7-x86_64
[+]                              ^pkgconf@1.6.0%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^automake@1.16.1%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^curl@7.63.0%gcc@8.2.0~darwinssl~gssapi~libssh~libssh2~nghttp2 arch=linux-centos7-x86_64
[+]              ^openssl@1.1.1b%gcc@8.2.0+systemcerts arch=linux-centos7-x86_64
[+]                  ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-x86_64
[+]          ^expat@2.2.5%gcc@8.2.0+libbsd arch=linux-centos7-x86_64
[+]              ^libbsd@0.9.1%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^gettext@0.19.8.1%gcc@8.2.0+bzip2+curses+git~libunistring+libxml2 patches=9acdb4e73f67c241b5ef32505c9ddf7cf6884ca8ea661692f21dca28483b04b8 +tar+xz arch=linux-centos7-x86_64
[+]              ^bzip2@1.0.6%gcc@8.2.0+shared arch=linux-centos7-x86_64
[+]                  ^diffutils@3.7%gcc@8.2.0 arch=linux-centos7-x86_64
[+]              ^libxml2@2.9.9%gcc@8.2.0~python arch=linux-centos7-x86_64
[+]                  ^libiconv@1.15%gcc@8.2.0 arch=linux-centos7-x86_64
[+]                  ^xz@5.2.4%gcc@8.2.0 arch=linux-centos7-x86_64
[+]              ^tar@1.31%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^libtool@2.4.6%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^pcre@8.42%gcc@8.2.0+jit+multibyte+utf arch=linux-centos7-x86_64
[+]      ^lua@5.3.5%gcc@8.2.0 arch=linux-centos7-x86_64
[+]          ^unzip@6.0%gcc@8.2.0 arch=linux-centos7-x86_64
```


Discussion:
Thanks for finding this issue @odoublewen.  I am able to reproduce the problem and will investigate.
Please checkout b76fc82, which seems to work fine for me.  We squashed a lot of commits into 4 so it looks like something slipped by.
@tldahlgren: that's included in current `develop` -- I get the error on `b76fc827e` too.
well, I get *an* error.  I do not get the specific error above.  I get this:

```
==> [2019-06-06-11:50:01.839800] Error: ProcessError: Command exited with status 1:
    '/Users/gamblin2/src/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.0-apple/lua-5.3.5-dzxkszegndv3xfbvzav6vo32ysrlptgl/bin/luarocks' '--tree=/Users/gamblin2/src/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.0-apple/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt' 'install' '/Users/gamblin2/src/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt/luafilesystem-1_7_0_2/rockspecs/luafilesystem-1.7.0-2.rockspec'

1 error found in build log:
     3    
  >> 4    Error: File not found: /Users/gamblin2/src/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt/luafilesystem-1_7_0_2/rockspecs/luafilesystem-1.7.0-2.rockspec
     5    Using /Users/gamblin2/src/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt/luafilesystem-1_7_0_2/rockspecs/luafilesystem-1.7.0-2.rockspec... switching to 'build' mode

See build log for details:
  /Users/gamblin2/src/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt/spack-build.out
Traceback (most recent call last):
  File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 765, in child_process
    return_value = function()
  File "/Users/gamblin2/src/spack/lib/spack/spack/package.py", line 1572, in build_process
    phase(self.spec, self.prefix)
  File "/Users/gamblin2/src/spack/lib/spack/spack/package.py", line 99, in phase_wrapper
    phase(spec, prefix)
  File "/Users/gamblin2/src/spack/var/spack/repos/builtin/packages/lua-luafilesystem/package.py", line 50, in install
  File "/Users/gamblin2/src/spack/lib/spack/spack/util/executable.py", line 189, in __call__
    proc.returncode, long_msg)
ProcessError: Command exited with status 1:
    '/Users/gamblin2/src/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.0-apple/lua-5.3.5-dzxkszegndv3xfbvzav6vo32ysrlptgl/bin/luarocks' '--tree=/Users/gamblin2/src/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.0-apple/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt' 'install' '/Users/gamblin2/src/spack/var/spack/stage/lua-luafilesystem-1_7_0_2-nr2fn4obpxax53sks5qighjb5x7czndt/luafilesystem-1_7_0_2/rockspecs/luafilesystem-1.7.0-2.rockspec'
```

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/lua-luafilesystem/package.py b/var/spack/repos/builtin/packages/lua-luafilesystem/package.py
--- a/var/spack/repos/builtin/packages/lua-luafilesystem/package.py
+++ b/var/spack/repos/builtin/packages/lua-luafilesystem/package.py
@@ -36,8 +36,7 @@ def rockspec(self):
         semver = version[0:3]
         tweak_level = version[3] if len(version) > 3 else 1
         fmt = os.path.join(
-            self.stage.path,
-            'luafilesystem-{version.underscored}',
+            self.stage.source_path,
             'rockspecs',
             'luafilesystem-{semver.dotted}-{tweak_level}.rockspec'
         )


Test patch: