Repository: spack/spack

Issue:
Installation issue: openfoam-org v7
Note: `spack debug report` fails:

> usage: spack debug [-h] SUBCOMMAND ...
> spack debug: error: argument SUBCOMMAND: invalid choice: 'report' choose from:
>     create-db-tarball

```console
$ uname -a
Linux login1.wally.unil.ch 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

$ spack -V
0.13.3-1359-09dfbf9
```

### Steps to reproduce the issue
```console
$ spack install openfoam-org@7 %gcc@8.3.0
$ spack load openfoam-org@7 %gcc@8.3.0
$ decomposePar 
decomposePar: error while loading shared libraries: libmetisDecomp.so: cannot open shared object file: No such file or directory
```
Note: the library can be found in the lib/dummy directory but likely should be considered when not asking for the variant "metis" (which works fine btw)


### Information on your system
[spack-db.master.09dfbf9.2020-04-08-130820.tar.gz](https://github.com/spack/spack/files/4450089/spack-db.master.09dfbf9.2020-04-08-130820.tar.gz)
[spack-build-env.txt](https://github.com/spack/spack/files/4450098/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/4450099/spack-build-out.txt)


<!-- Some packages have maintainers who have volunteered to debug build failures. Run `spack maintainers <name-of-the-package>` and @mention them here if they exist. -->

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers
- [x] I have uploaded the build log and environment files
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:

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
@@ -45,6 +45,7 @@
 from spack.pkg.builtin.openfoam import rewrite_environ_files
 from spack.pkg.builtin.openfoam import mplib_content
 from spack.pkg.builtin.openfoam import OpenfoamArch
+from spack.util.environment import EnvironmentModifications
 
 
 class OpenfoamOrg(Package):
@@ -138,15 +139,14 @@ def config(self):
         return settings
 
     def setup_run_environment(self, env):
-        # This should be similar to the openfoam package,
-        # but sourcing the etc/bashrc here seems to exit with an error.
-        # ... this needs to be examined in more detail.
-        #
-        # Minimal environment only.
-        env.set('FOAM_PROJECT_DIR', self.projectdir)
-        env.set('WM_PROJECT_DIR', self.projectdir)
-        for d in ['wmake', self.archbin]:  # bin already added automatically
-            env.prepend_path('PATH', join_path(self.projectdir, d))
+        bashrc = self.prefix.etc.bashrc
+        try:
+            env.extend(EnvironmentModifications.from_sourcing_file(
+                bashrc, clean=True
+            ))
+        except Exception as e:
+            msg = 'unexpected error when sourcing OpenFOAM bashrc [{0}]'
+            tty.warn(msg.format(str(e)))
 
     def setup_dependent_build_environment(self, env, dependent_spec):
         """Location of the OpenFOAM project directory.
@@ -386,5 +386,3 @@ def install_links(self):
                 if os.path.isfile(f)
             ]:
                 os.symlink(f, os.path.basename(f))
-
-# -----------------------------------------------------------------------------


Test patch: