Fortls interfacing with Modern Fortran in VS Code

Hi everyone,

Disclaimer, I am very new to Fortran and computation in general. I am attempting to incorporate Fortls into Modern Fortran in VS Code. I am running a remote session of Windows Subsystems for Linux with Ubuntu and have downloaded Fortls via pip on WSL. I have directed VS Code to Fortls via the path in my WSL library, as recommended by user gnikit in the thread titled “Fortls installation & Autocomplete Suggestions” here, as shown below:

image

However, I still receive the usual message recommending that I install Fortls. Additionally, my Modern Fortran output does not list Fortls as being initialized.

I have also installed Fortls via pip on my Windows library and attempted to direct VS Code via that path instead and I am met with the same issues.

If anyone has an idea as to what is going wrong or ways to troubleshoot this, that would be very appreciated!

Hi and welcome to the forum. That path does not look right to me, should be /path/to/bin/fortls. You need to add the binary name i.e. fortls at the very end.

1 Like

Thank you for the reply. I have updated the path to include the binary name, now “\wsl.localhost\Ubuntu\usr\local\bin\fortls”; however, I am met with the same issue. I’ve included the Modern Fortran output below in case that may be helpful:

There is also another message upon starting VS code advising me to switch from the Windows (/mnt/) file system to the Linux (~/home) file system. Could this be relevant to the issue?

Thank you for the help!

I think the path separators should be / not .
The second warning is from vscode not the modern Fortran extension, using that recommendation is up to you. Usually the Microsoft team is right about their recommendations.

1 Like

I attempted to specify the path as these variations:
//wsl.localhost/Ubuntu/usr/local/bin
/wsl.localhost/Ubuntu/usr/local/bin
wsl.localhost/Ubuntu/usr/local/bin
\wsl.localhost\Ubuntu\usr\local\bin
\wsl.localhost\Ubuntu\usr\local\bin
wsl.localhost\Ubuntu\usr\local\bin

and unfortunately meet the same result. The only path that is able to reach fortls in Ubuntu in the file explorer is “\wsl.localhost\Ubuntu\usr\local\bin”.

In the output of Modern Fortran, it specifies gfortran as being located in “/usr/bin/gfortran”, but my computer when I copy the path shows “\wsl.localhost\Ubuntu\usr\bin\gfortran”. I am not sure why the distinction is made in the Modern Fortran output, but the path to gfortran is not specified in VS Code and is instead accessed via the remote WSL session. This is the only difference I can see between VS Code incorporating gfortran versus fortls.

Any advice is much appreciated! I may attempt to move my entire work environment to the Linux file system to see if that helps.

Apologies for my lack of knowledge! The path “/usr/local/bin/fortls” works, so I needed to omit the “wsl.local host/Ubuntu/” part and format in the Linux path convention of “/”. Thank you for your help!