This solves the problem: https://spack.readthedocs.io/en/latest/module_file_support.html#customize-environment-modifications
Run spack config edit modules
to edit modules.yaml
and add:
modules:
prefix_inspections:
./lib:
- LD_LIBRARY_PATH
- LIBRARY_PATH
./lib64:
- LD_LIBRARY_PATH
- LIBRARY_PATH
./include:
- CPATH