Problems installing Modern Fortran VS code extension

Hello,

I’ve been very recently encountering problems installing the Modern Fortran extension for Visual Studio code on openSUSE Leap 15.3 .

After the failed installation it gives me the following errors:

Linter can't be found in $PATH. Update your settings with a proper path or disable the linter.

Error launching fortls: Please check that all selected options are supported by your language server version.

Deprecated settings have been detected in your settings. Please update your settings to make use of the new names. The old names will not work.

Anyone knows how to handle that?

Many Thanks

try pip install fortls and tell me if it manages to install after that ?

Thank you.

The fortls related error is gone but the other two remain and the installation continues to fail.

Sorry I’ve to say that only the linter error has disappeared.

1 Like

Try referring to this answer and see if it helps ?

also try looking at this:
https://gnikit.github.io/fortls/editor_integration.html#visual-studio-code

If not then , I hope @gnikit will chime in.

1 Like

Unfortunately neither solution seems to work. The extension has been working for long time and only crashed some weeks ago.

Sorry I wasn’t of much help :frowning:

Don’t worry.
I think it can be related to the new release as it’s been working without issues until a couple weeks ago.

1 Like

I experienced similar behaviour recently on Ubuntu. There was a problem with one of the Python packages that fortls depends on. Luckily it was auto-magically fixed after a few days.

Maybe try something like

fortls --version

at the command prompt to see if it sheds some light on the problem?

2 Likes

Apologies for the delay @Rob777 I have been rather busy and didn’t see this.

Linter

So the linter would refer to gfortran or ifort. We changed the option

"fortran.linter.compilerPath": ""

To mean the full path to the compiler you are using for the linter instead of compiler’s root.
So now you have to input /my/custom/dir/gfortran instead of /my/custom/dir if you want to use the non-default compiler version.

fortls - Language Server

Nothing has changed in the language server side of things so I am not sure what that warning is about.
Please paste all the options that you are passing the fortls along with the version that you are using.

Deprecated settings

A lot of settings have been renamed and some have become obsolete. Please open your Settings to see which ones, they are highlighted with deprecation warnings.

1 Like

Thank you so much.

The field

"fortran.linter.compilerPath": ""

was empty so adding the full path to gfortran solved the problem related to linter.

Please find in the image below the only two highlighted errors in my settings.

Below is my settings.json :

{
    "workbench.colorTheme": "Default Dark+",
    "fortran.gfortranExecutable": "/usr/bin/gfortran-11",
    "fortran.includePaths": [  ],
    "editor.fontSize": 16,
    "fortran.linter.compilerPath": "/usr/bin/gfortran-11",
    "fortran.fortls.path": "/home/username/.local/bin/fortls",
    "fortran.linter.extraArgs": [
    
    ],
    "fortran.formatting.findentArgs": [
    
    ]
      
}

Thanks

1 Like

Good to hear :slight_smile:


If you see in your settings.json 2 of your settings are underlined with yellow color,

"fortran.gfortranExecutable": "/usr/bin/gfortran-11",
"fortran.includePaths": [  ],

Remove those and the deprecation warnings will go away.

1 Like

Thank you so much!
There’s the fortls warning left… :sweat_smile:

The path to fortls is correct

user@localhost:~> ls /home/user/.local/bin/fortls
/home/user/.local/bin/fortls

what version are you using? fortls --version

Mmm I get this error

u@localhost:~/dev> fortls --version
Traceback (most recent call last):
  File "/home/u/.local/bin/fortls", line 5, in <module>
    from fortls.__init__ import main
  File "/home/u/.local/lib/python3.6/site-packages/fortls/__init__.py", line 10, in <module>
    from .helper_functions import resolve_globs, only_dirs
  File "/home/u/.local/lib/python3.6/site-packages/fortls/helper_functions.py", line 1
    from __future__ import annotations
    ^
SyntaxError: future feature annotations is not defined

You need to have python 3.7 Or higher for fortls to work. I suspect you are using py3.6 which has reached end of life.

You can install a higher version of python or download miniconda locally and install fortls through that. If you use miniconda I would still recommend you install fortls with pip and not conda-forge

Thank you so much! The problem is solved!

For anyone using open-suse

sudo zypper in python39
then
pip3.9 install fortls

That’s all.

1 Like

mark it as a solution :slight_smile: