# find\_package fails for MPI in build directory with long absolute path (Linux)

**URL:** https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192
**Category:** Usage
**Tags:** os:linux
**Created:** [December 13, 2024, 12:56am UTC](https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192 "2024-12-13T00:56:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![KTRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@KTRR](https://discourse.cmake.org/u/KTRR)
#### Post date: [December 13, 2024, 12:56am UTC](https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192/1 "2024-12-13T00:56:23Z")

</div>

On a Linux system with a build directory path longer than ~256 characters\* `find_package(MPI REQUIRED)` is failing because `missing: MPI_Fortran_WORKS`. Is there something I can do to fix or diagnose what might be going wrong?

\*In other words I’m running `cmake ..` from `/very/long/path/to/build`, where `len('/very/long/path/to/build')>=254` is bad, but length 253 is fine.

---

<div class="post-metadata">

### Author: ![KTRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/848f3c/32.png) [@KTRR](https://discourse.cmake.org/u/KTRR)
#### Post date: [December 13, 2024, 7:47pm UTC](https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192/2 "2024-12-13T19:47:39Z")

</div>

This issue is caused by buggy Intel Fortran compilers (at least ifort 2021.6.0 is affected).

With that specific compiler version, the command `ifort -I <mpi include> -c /very/long/path/test_mpi.f90 -o test_mpi.f90.o` will fail to find valid MPI includes, causing the `try_compile` calls in `FindMPI.cmake` to fail.
