Repository: spack/spack

Issue:
Missing symlinks for view et al. for package vim
Some of my vim builds end up with the symbolic links emplaced for `view` *et al.*, but others don't.  All of these are driven by the same script.

**TL;DR** 

1. Do other folks see this?
2. Is there perhaps a problem with running the vim build in parallel?

```
/blah/spack/v0.0.4/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin:
total 2560
lrwxrwxrwx 1 hartzelg users       3 Apr  3 12:44 ex -> vim
lrwxrwxrwx 1 hartzelg users       3 Apr  3 12:44 rview -> vim
lrwxrwxrwx 1 hartzelg users       3 Apr  3 12:44 rvim -> vim
lrwxrwxrwx 1 hartzelg users       3 Apr  3 12:44 view -> vim
-rwxr-xr-x 1 hartzelg users 2235632 Apr  3 12:44 vim
lrwxrwxrwx 1 hartzelg users       3 Apr  3 12:44 vimdiff -> vim
-rwxr-xr-x 1 hartzelg users    2099 Apr  3 12:44 vimtutor
-rwxr-xr-x 1 hartzelg users   18864 Apr  3 12:44 xxd

/blah/spack/v0.0.5/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin:
total 2560
-rwxr-xr-x 1 hartzelg users 2235632 Apr  5 23:31 vim
-rwxr-xr-x 1 hartzelg users    2099 Apr  5 23:31 vimtutor
-rwxr-xr-x 1 hartzelg users   18864 Apr  5 23:31 xxd

/blah/spack/v0.0.6/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin:
total 2560
lrwxrwxrwx 1 hartzelg users       3 Apr 12 11:04 rview -> vim
lrwxrwxrwx 1 hartzelg users       3 Apr 12 11:04 rvim -> vim
-rwxr-xr-x 1 hartzelg users 2235632 Apr 12 11:04 vim
lrwxrwxrwx 1 hartzelg users       3 Apr 12 11:04 vimdiff -> vim
-rwxr-xr-x 1 hartzelg users    2099 Apr 12 11:04 vimtutor
-rwxr-xr-x 1 hartzelg users   18864 Apr 12 11:04 xxd

/blah/spack/v0.0.7/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin:
total 2560
-rwxr-xr-x 1 hartzelg users 2235632 Apr 13 19:44 vim
-rwxr-xr-x 1 hartzelg users    2099 Apr 13 19:44 vimtutor
-rwxr-xr-x 1 hartzelg users   18864 Apr 13 19:44 xxd

/blah/spack/v0.0.8/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin:
total 2560
-rwxr-xr-x 1 hartzelg users 2235632 Apr 15 20:05 vim
-rwxr-xr-x 1 hartzelg users    2099 Apr 15 20:05 vimtutor
-rwxr-xr-x 1 hartzelg users   18864 Apr 15 20:05 xxd
```
Paging through `.../vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/.spack/build.out` I see that it created the links without any complaints, but in the middle it creates the `.../bin` directory.

```
cd /blah/spack/v0.0.8/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin; ln -s vim view
cd /blah/spack/v0.0.8/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin; ln -s vim rvim
mkdir /blah/spack/v0.0.8/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin
cd /blah/spack/v0.0.8/opt/spack/linux-centos7-x86_64/gcc-5.4.0/vim-8.0.0454-zngph6kn2ucnfgrcc3x2sl235q7pjdyn/bin; ln -s vim rview
```

Makes me wonder if something is racing....


Discussion:
Looks like a race condition to me. I would add `parallel=False` and see if that solves the problem.
Would running `spack install -j 1 vim ...` have the same effect (for testing, then I can continue to build from the same package tree)?
Yep!
Time to go `heisenbug` hunting!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/vim/package.py b/var/spack/repos/builtin/packages/vim/package.py
--- a/var/spack/repos/builtin/packages/vim/package.py
+++ b/var/spack/repos/builtin/packages/vim/package.py
@@ -129,3 +129,9 @@ def configure_args(self):
             configure_args.append("--enable-cscope")
 
         return configure_args
+
+    # Run the install phase with -j 1.  There seems to be a problem with
+    # parallel builds that results in the creation of the links (e.g. view)
+    # to the vim binary silently failing.
+    def install(self, spec, prefix):
+        make('install', parallel=False)


Test patch: