Repository: spack/spack

Issue:
Installation issue: openfoam-org v7
<!--*Thanks for taking the time to report this build failure. To proceed with the
report please:*
1. Title the issue "Installation issue: <name-of-the-package>".
2. Provide the information required below.

We encourage you to try, as much as possible, to reduce your problem to the minimal example that still reproduces the issue. That would help us a lot in fixing it quickly and effectively!
-->


### Spack version
<!-- Add the output to the command below -->
```console
$ spack --version
0.13.3-1344-ce52a26
```

### Steps to reproduce the issue

```console
$ spack install openfoam-org@7%gcc@8.3.0
...
==> 186626: openfoam-org: Building openfoam-org [Package]
==> 186626: openfoam-org: Executing phase: 'configure'
==> 186626: openfoam-org: Executing phase: 'build'
==> 186626: openfoam-org: Executing phase: 'install'
==> 186626: openfoam-org: Successfully installed openfoam-org
  Fetch: 0.10s.  Build: 5m 46.71s.  Total: 5m 46.81s.
```
Seems to install normally but many expected binaries are actually missing. In the build log we have this:
> fatal error: FlexLexer.h: No such file or directory

```console
flex -+ -o/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C -f surfaceFo
rmats/stl/STLsurfaceFormatASCII.L && g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno
-attributes -O3 -Wl,-rpath,/dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/platforms/linux64GccDPInt32RpathOpt/lib -DNoRepository -
ftemplate-depth-100 -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/fileFormats/lnInclude -IlnInclude -I. -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-
7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OpenFOAM/lnInclude -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OSspecific/POSIX/lnInclude   -fPIC -Wno-o
ld-style-cast -Wno-unused-local-typedefs -Wno-array-bounds -c /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfa
ceFormats/stl/STLsurfaceFormatASCII.L.C -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsu
rfaceFormatASCII.o
/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C:301:10: fatal error: FlexLexer.h: No such file or directory
 
          ^            
compilation terminated.
make: *** [/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.o] Error 1
make: *** Waiting for unfinished jobs....
==> 186626: openfoam-org: Executing phase: 'install'
... 
```

### Platform and user environment

<!-- Please report your OS here:
```commandline
$ uname -a 
Linux nuvolari 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:	Ubuntu 18.04.1 LTS
``` 
and, if relevant, post or attach:

- `packages.yaml`
- `compilers.yaml`

to the issue
-->
Linux 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

### Additional information

```console
$ spack spec --install-status openfoam-org@7%gcc@8.3.0
Input spec
--------------------------------
 -   openfoam-org@7%gcc@8.3.0

Concretized
--------------------------------
[+]  openfoam-org@7%gcc@8.3.0~float32~int64~metis patches=73103e6b1bdbf3b1e0d517cbbd11562e98c6e9464df5f43e5125e9a5b457d1c5,ecfa93afa8900f583a23c179db7cf0dc066828a9fd872e061164f21301c2a222 +source arch=linux-centos7-skylake_avx512
[^]      ^cmake@3.16.2%gcc@8.3.0~doc+ncurses+openssl+ownlibs~qt arch=linux-centos7-skylake_avx512
[^]          ^ncurses@6.1%gcc@8.3.0~symlinks~termlib arch=linux-centos7-skylake_avx512
[^]              ^pkgconf@1.6.3%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]          ^openssl@1.0.2k%gcc@8.3.0+systemcerts arch=linux-centos7-skylake_avx512
[^]      ^flex@2.6.4%gcc@8.3.0+lex patches=09c22e5c6fef327d3e48eb23f0d610dcd3a35ab9207f12e0f875701c677978d3 arch=linux-centos7-skylake_avx512
[^]          ^autoconf@2.69%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]              ^m4@1.4.16%gcc@8.3.0+sigsegv arch=linux-centos7-skylake_avx512
[^]              ^perl@5.30.1%gcc@8.3.0+cpanm+shared+threads arch=linux-centos7-skylake_avx512
[^]                  ^gdbm@1.18.1%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]                      ^readline@8.0%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]          ^automake@1.16.1%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]          ^bison@3.4.2%gcc@8.3.0 patches=89aa362716d898edd0b5c6ae4208dc1b6992887774848a09e8021afd676f7d61 arch=linux-centos7-skylake_avx512
[^]              ^diffutils@3.7%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]                  ^libiconv@1.16%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]              ^help2man@1.47.11%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]                  ^gettext@0.20.1%gcc@8.3.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-centos7-skylake_avx512
[^]                      ^bzip2@1.0.8%gcc@8.3.0+shared arch=linux-centos7-skylake_avx512
[^]                      ^libxml2@2.9.9%gcc@8.3.0~python arch=linux-centos7-skylake_avx512
[^]                          ^xz@5.2.4%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]                          ^zlib@1.2.11%gcc@8.3.0+optimize+pic+shared arch=linux-centos7-skylake_avx512
[^]                      ^tar@1.32%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]          ^findutils@4.6.0%gcc@8.3.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-centos7-skylake_avx512
[^]              ^libtool@2.4.6%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]              ^texinfo@6.5%gcc@8.3.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-centos7-skylake_avx512
[+]      ^openmpi@3.1.5%gcc@8.3.0~cuda+cxx_exceptions fabrics=none ~java~legacylaunchers~memchecker~pmi schedulers=none ~sqlite3~thread_multiple+vt arch=linux-centos7-skylake_avx512
[^]          ^hwloc@1.11.11%gcc@8.3.0~cairo~cuda~gl+libxml2~nvml+pci+shared arch=linux-centos7-skylake_avx512
[^]              ^libpciaccess@0.13.5%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]                  ^util-macros@1.19.1%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[^]              ^numactl@2.0.12%gcc@8.3.0 arch=linux-centos7-skylake_avx512
[+]      ^scotch@6.0.8%gcc@8.3.0+compression~esmumps~int64~metis+mpi+shared arch=linux-centos7-skylake_avx512
``` 

```console
$ spack log-parse --show=errors,warnings /dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/.spack/spack-build-out.txt 
2 errors
2 warnings
     17      gcc -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -O3   -fPIC dirToString.c -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/w
             make/platforms/linux64Gcc/dirToString
     18      flex wmkdep.l; \
     19      gcc -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -O3   -fPIC lex.yy.c -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/wmake/
             platforms/linux64Gcc/wmkdep
  >> 20      lex.yy.c:1286:16: warning: 'input' defined but not used [-Wunused-function]
     21       #else
     22                      ^
  >> 23      lex.yy.c:1243:17: warning: 'yyunput' defined but not used [-Wunused-function]
     24      
     25                       ^
     26      Allwmake: no ThirdParty directory found - skipping

     ...

     1154    g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -Wl,-rp
             ath,/dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/platforms/linux64GccDPInt32RpathOpt/lib -DNoRepository -ftemplate
             -depth-100 -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/fileFormats/lnInclude -IlnInclude -I. -I/tmp/eorliac/spack-stage/spack-stage-openfoam
             -org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OpenFOAM/lnInclude -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OSspecific/POSIX/lnInc
             lude   -fPIC -c surfaceFormats/stl/STLsurfaceFormatCore.C -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/s
             urfMesh/surfaceFormats/stl/STLsurfaceFormatCore.o
     1155    g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -Wl,-rp
             ath,/dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/platforms/linux64GccDPInt32RpathOpt/lib -DNoRepository -ftemplate
             -depth-100 -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/fileFormats/lnInclude -IlnInclude -I. -I/tmp/eorliac/spack-stage/spack-stage-openfoam
             -org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OpenFOAM/lnInclude -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OSspecific/POSIX/lnInc
             lude   -fPIC -c surfaceFormats/stl/STLsurfaceFormatRunTime.C -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/sr
             c/surfMesh/surfaceFormats/stl/STLsurfaceFormatRunTime.o
     1156    flex -+ -o/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.
             C -f surfaceFormats/stl/STLsurfaceFormatASCII.L && g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-paramete
             r -Wno-invalid-offsetof -Wno-attributes -O3 -Wl,-rpath,/dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/platforms/linu
             x64GccDPInt32RpathOpt/lib -DNoRepository -ftemplate-depth-100 -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/fileFormats/lnInclude -IlnInclude 
             -I. -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/src/OpenFOAM/lnInclude -I/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvl
             jpfzvpwyx6bnz/OpenFOAM-7/src/OSspecific/POSIX/lnInclude   -fPIC -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds -c /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3
             nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C -o /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvl
             jpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.o
  >> 1157    /tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L.C:301:10: 
             fatal error: FlexLexer.h: No such file or directory
     1158    
     1159              ^
     1160    compilation terminated.
  >> 1161    make: *** [/tmp/eorliac/spack-stage/spack-stage-openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz/OpenFOAM-7/platforms/linux64GccDPInt32RpathOpt/src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.o
             ] Error 1
     1162    make: *** Waiting for unfinished jobs....
     1163    ==> 186626: openfoam-org: Executing phase: 'install'
     1164    ==> [2020-04-04-15:59:41.901451, 79589] Installing Allwmake to /dcsrsoft/sandbox/eorliac/spack/opt/spack/linux-centos7-skylake_avx512/gcc-8.3.0/openfoam-org-7-p7veu3cz7cm2p3nznvljpfzvpwyx6bnz


Rebuilding the package with the following options:
```console
$ spack -d install -j 1 <spec>
...
```

Attached: 

[spack-cc-openfoam-org-p7veu3c.in.log](https://github.com/spack/spack/files/4431719/spack-cc-openfoam-org-p7veu3c.in.log)
[spack-cc-openfoam-org-p7veu3c.out.log](https://github.com/spack/spack/files/4431724/spack-cc-openfoam-org-p7veu3c.out.log)



### General information

- [x] I have run `spack --version` and reported the version of Spack
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:
@olesenm 
Confirmed with:
* **Spack:** 0.14.1-534-bbc10ee9c
* **Python:** 3.7.4
* **Platform:** linux-ubuntu18.04-broadwell

Seems exactly the same as #10956. I'm trying that solution and will submit a PR soon.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/openfoam-org/package.py b/var/spack/repos/builtin/packages/openfoam-org/package.py
--- a/var/spack/repos/builtin/packages/openfoam-org/package.py
+++ b/var/spack/repos/builtin/packages/openfoam-org/package.py
@@ -84,7 +84,7 @@ class OpenfoamOrg(Package):
 
     depends_on('mpi')
     depends_on('zlib')
-    depends_on('flex',  type='build')
+    depends_on('flex')
     depends_on('cmake', type='build')
 
     # Require scotch with ptscotch - corresponds to standard OpenFOAM setup


Test patch: