Fpm not finding compiler

I installed fpm on Ubuntu 24.04 using a snap package and set up the first_steps sample project. When I run “fortran-fpm run” I get an error which says that fpm cannot find the compiler gfortran. However gfortran is definitely in my PATH and is located at /bin/gfortran. The log file I get has the line
sh: 1: /bin/gfortran: not found

Is there an environment variable needing to be set? Note that fortran-fpm is the snap package command for fpm…

You could try setting the environment variable FPM_FC,

> export FPM_FC=`which gfortran`

Alternatively you can override on the command line using --compiler <compiler>:

$ fpm run --compiler `which gfortran`
 + mkdir -p build/dependencies
test_fpm.f90                           done.
libtest_fpm.a                          done.
main.f90                               done.
test_fpm                               done.
[100%] Project compiled successfully.
 Hello, test_fpm!

But by default it will try to use gfortran.

How familiar are you with snap? It intentionally runs the applications in a container with limited access to the host system. That is a very unusual way to install fpm. If you install it as a conventional application and/or build it from the single-source-file it will run in a normal shell with access to the base operating system applications which I assume is where you installed the compiler (?).

https://fpm.fortran-lang.org/install/index.html

Yes that was the problem. snap runs in a container and restricts the environment making it cumbersome to run dev apps. I downloaded the binary and it works fine. Pity that fpm is not in the Debian/Ubuntu apt repo to avoid these complications or that the snap docs for fortran-fpm are not more helpful

I often had trouble finding compilers in my Linux system after installing them until I realised that commands like these tell you where they are:

locate bin/gfortran
locate bin/ifx 

You may also find some old versions lurking in your machine.