The problem is solved with this PR
Make PETSc an optional dependency of fenics-dolfinx by chrisrichardson · Pull Request #49837 · spack/spack
fenics-dolfinx