# Dolfinx in spack

**URL:** <https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706>\
**Category:** installation\
**Created:** [March 17, 2023, 4:05pm UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706 "2023-03-17T16:05:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![androd](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/androd/32/1055_2.png) [@androd](https://fenicsproject.discourse.group/u/androd)\
**Post date:** [March 17, 2023, 4:05pm UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/1 "2023-03-17T16:05:00Z")

</div>

Dear FEniCS community,  
I’m trying to install dolfinx on a HPC resource via spack using the GitHub [instructions](https://github.com/FEniCS/dolfinx#spack).  
I’m facing two problems:

1. some packages like gmsh and matplotlib were not installed and I added them manually through pip, not sure it is the right way to add packages on spack, but I couldn’t find a better solution.
2. through `spack find` I can see that `py-petsc4py@3.18.3` is installed but seems that mumps (and umfpack) is not working and I obtain this error:

```auto
[0] Could not locate solver type mumps for factorization type LU and matrix type seqaij. Perhaps you must ./configure with --download-mumps

```

If someone could point some tips out, it would be very helpful.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [March 17, 2023, 4:29pm UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/2 "2023-03-17T16:29:32Z")

</div>

As PETSc has mumps as a variant, you need to use the variants command in spack:

> <https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/petsc/package.py#L92>

[https://spack.readthedocs.io/en/latest/packaging\_guide.html#variants](https://spack.readthedocs.io/en/latest/packaging_guide.html#variants)  
For instance, you can see: [dolfinx/spack.yml at main · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/blob/main/.github/workflows/spack.yml#L57)  
adds adios2 which is a variant in: [spack/package.py at develop · spack/spack · GitHub](https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/fenics-dolfinx/package.py#L73)

You can also see: [Basic Usage — Spack 0.20.0.dev0 documentation](https://spack.readthedocs.io/en/latest/basic_usage.html#specs-dependencies)

You can also add gmsh through spack: [Package List — Spack 0.20.0.dev0 documentation](https://spack.readthedocs.io/en/latest/package_list.html#gmsh)

---

<div class="post-metadata">

**Author:** ![androd](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/androd/32/1055_2.png) [@androd](https://fenicsproject.discourse.group/u/androd)\
**Post date:** [March 21, 2023, 9:50am UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/4 "2023-03-21T09:50:51Z")

</div>

I solved it in the following way, not sure it is the best one though:

1. Installed dolfinx via spack as in [GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment](https://github.com/FEniCS/dolfinx#spack)
2. Added packages by modifying the file spack/var/spack/environments/fenicsx-env/spack.yaml  
2a. specs:[py-fenics-dolfinx, other-packages]  
2b. unify: when\_possible  
the list of packages is available here: [Package List — Spack 0.20.0.dev0 documentation](https://spack.readthedocs.io/en/latest/package_list.html#gmsh)

> [@dokken](#):
>
> You can also add gmsh through spack: [Package List — Spack 0.20.0.dev0 documentation](https://spack.readthedocs.io/en/latest/package_list.html#gmsh)

1. I added gmsh to the specs but still I couldn’t manage to import `dolfinx.io.gmshio` so I installed py-gmsh through pip: [Installation - pip documentation v23.3.1](https://pip.pypa.io/en/stable/installation/#get-pip-py)
2. To switch on the variant mumps in PETSc I modified the file spack/var/spack/repos/builtin/packages/fenics-dolfinx/package.py at the line:  
`depends_on("petsc+mpi+shared+mumps")`

It is actually working now, but I imagine there is a simpler way to get it done.  
Thank you again!  
ar

---

<div class="post-metadata">

**Author:** ![xiaolaner](https://avatars.discourse-cdn.com/v4/letter/x/f17d59/32.png) [@xiaolaner](https://fenicsproject.discourse.group/u/xiaolaner)\
**Post date:** [June 30, 2023, 7:35am UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/5 "2023-06-30T07:35:24Z")

</div>

Hi, androd,

About the variant mumps in PETSc, I modified the `depends_on("petsc+mpi+shared+mumps")`. It seemed not to work. Is there other operation?

Thanks

---

<div class="post-metadata">

**Author:** ![androd](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/androd/32/1055_2.png) [@androd](https://fenicsproject.discourse.group/u/androd)\
**Post date:** [June 30, 2023, 10:10am UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/6 "2023-06-30T10:10:47Z")

</div>

Dear xiaolaner,  
I’m not an expert at all, but just for completeness, which error do you get?  
Thanks

---

<div class="post-metadata">

**Author:** ![xiaolaner](https://avatars.discourse-cdn.com/v4/letter/x/f17d59/32.png) [@xiaolaner](https://fenicsproject.discourse.group/u/xiaolaner)\
**Post date:** [June 30, 2023, 11:12am UTC](https://fenicsproject.discourse.group/t/dolfinx-in-spack/10706/7 "2023-06-30T11:12:19Z")

</div>

Dear androd,  
I modified the file as your method. It also has the same error `Could not locate solver type mumps for factorization type LU and matrix type seqaij. Perhaps you must ./configure with --download-mumps`. So I wonder if I need other operation.  
The steps are as:

1. modified the file spack/var/spack/repos/builtin/packages/fenics-dolfinx/package.py at the line:

```auto
depends_on("petsc+mpi+shared+mumps")

```

1. `spack load py-fenics-doflinx` again
