Modern Fortran Error starting fortls error

I keep getting this error, even though I have fortls in my path in .json file. “Modern Fortran Error starting fortls: Check that fortls is in your PATH or that “fortran.fortls.path” is pointing to a fortls binary.”

I had a similar issue, here is what worked for me. I opened the VS Code and for the Modern Fortran Extension Settings → Language Server → Fortran > Fortls: Path: I reset to the default which is just fortls with no single or double quotes around it. This is the name of the .exe file. In the settings.json file I made sure there was no path to the file. THEN, I added the actual path to the fortls.exe to the environmental variable for system in Windows. This path for my installation via Python pip is: C:\Users\XXXXX\AppData\Local\Programs\Python\Python311\bin\ where XXXX is my username, i.e. sometimes called ‘home’. Note you do NOT include the .exe name just up to the folder that holds it which in my case Python installed in \bin\ Why does this work, because now VS Code will just submit the name fortls as the executable and since it is in my environmental variable path file it finds the .exe and executes it.

@Space_Ghost Appreciate this, it finally worked for me. I had given up on getting this to work for Windows until this.