# Configuring fpm + Modern Fortran + fortls on VSCode issues

**URL:** <https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912>\
**Category:** Visual Studio Code\
**Created:** [April 25, 2024, 11:15pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912 "2024-04-25T23:15:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DCLopes](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DCLopes](https://fortran-lang.discourse.group/u/DCLopes)\
**Post date:** [April 25, 2024, 11:15pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/1 "2024-04-25T23:15:03Z")

</div>

I’m pretty new to Fortran, so pardon if these questions are basic. i’ve installed fpm, Modern Fortran extension to VSCode and fortls, created a new project with _fpm new_. I’ve added stdlib as one of my dependencies on the fpm.toml file and ran fpm build. This is the end result:

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/2/256399237260e205f47a76028d13de6a48315161.png)

So far so good, but my Problems tab is showing 2k+ issues, all of them on the dependencies. Is there any way of removing the dependencies from the error checking, while also keeping the libraries visible from VSCode to avoid the “Cannot open module foo.mod” message?

I imagined that the option would be this “Exclude Directories” thing, but I can’t manage to make it work. I’ve added all combinations of glob patterns trying to exclude the build directory, but no luck.

Additionally, I can’t interact with fortls through the command line. If I try, I get an unresponsive command prompt.

Any help is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [April 26, 2024, 11:21am UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/2 "2024-04-26T11:21:52Z")

</div>

> [@DCLopes](#):
>
> So far so good, but my Problems tab is showing 2k+ issues, all of them on the dependencies.

Can you post a few of these issues. They can be originating from either VSCode’s linter or fortls. My bet is the former. To appease the linter, **after you have built with fpm** , using something like this would probably work

```json
  "fortran.linter.includePaths": [
    "${workspaceFolder}/build/**"
  ],

```

Please attach your full VSCode and fortls settings along with the respected versions, so we are on the same page.

> [@DCLopes](#):
>
> Additionally, I can’t interact with fortls through the command line. If I try, I get an unresponsive command prompt.

fortls is a server to the code editor, users are not meant to interact with it directly. For debugging and developers we have a set of options that we use [Configuration options - fortls](https://fortls.fortran-lang.org/options.html#debug-options-command-line-only). I would also suggest having a read of the whole Configuration options page not just the debug section, and letting us know what is not clear for novices such as yourself so that we can improve it.

---

<div class="post-metadata">

**Author:** ![DCLopes](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DCLopes](https://fortran-lang.discourse.group/u/DCLopes)\
**Post date:** [April 26, 2024, 8:06pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/3 "2024-04-26T20:06:41Z")

</div>

VSCode is 1.88.1, with Modern Fortran (v3.4.2024041503 (pre-release)) and fortls 3.0.0rc2.

I haven’t changed much about VSCode settings except for playing around with excludeDirectories, but I can’t seem to remove it from the linter.

```auto
{
    "[FortranFreeForm]": {

    },
    "fortran.linter.compilerPath": "gfortran",
    "workbench.iconTheme": "vscode-icons",
    "code-runner.executorMap": {...
    },
    "files.autoSave": "afterDelay",
    "fortran.fortls.configure": "fortls",
    "fortran.logging.level": "Debug",
    "fortran.fortls.excludeDirectories": [
        "build/**",
        "/build/",
        "/build/**",
        "build/",
        "build",
        "build/dependencies/**",
        "/build/dependencies/**",
        "/build/dependencies/"
    ],
    "fortran.linter.includePaths": [
        "${workspaceFolder}/build/**"
      ],
    "emmet.preferences": {

    }
}

```

All of the issues are on the dependencies .f files, like so:

 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/8/8b2354924cc2b8806f002e445a97d8c2be435eb1.png)

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [April 27, 2024, 1:41pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/4 "2024-04-27T13:41:57Z")

</div>

The diagnostics errors are from fortls. Here is a config that should work

```json
    // If you have a lot of dependencies you might want to fine-tune
    // your REGEX so that the linter does not seek .mod and .smod files
    // in so many directories
    "fortran.linter.includePaths": [
        "${workspaceFolder}/build/**",
        "${workspaceFolder}/src/**",
    ],
    // Previous comment applies here as well
    "fortran.fortls.directories": [
        "./src/**",
        "./build/dependencies/**"
    ],

```

All the other fortran settings are redundant or incorrect.

---

<div class="post-metadata">

**Author:** ![DCLopes](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DCLopes](https://fortran-lang.discourse.group/u/DCLopes)\
**Post date:** [April 27, 2024, 4:54pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/5 "2024-04-27T16:54:43Z")

</div>

I’ve added the config that you’ve suggested and removed all other configs, but the same behavior continues, the dependencies folder is included in the error checking.

every time I restart VSCode and open my project folder, it reads the full contents of the dependencies folder like this:  
 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/c/c3c3c84ce37c1f1abf696ea3de0a5ee27a9339cc.png)

---

<div class="post-metadata">

**Author:** ![gnikit](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/gnikit/32/1213_2.png) [@gnikit](https://fortran-lang.discourse.group/u/gnikit)\
**Post date:** [April 27, 2024, 5:23pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/6 "2024-04-27T17:23:44Z")

</div>

> [@DCLopes](#):
>
> every time I restart VSCode and open my project folder, it reads the full contents of the dependencies folder like this:

This is a separate issue from the ones mentioned. The pre-release has a feature enabled that will attempt to run all your sources through the linter. Disable it

```json
"fortran.linter.initialize": false

```

---

<div class="post-metadata">

**Author:** ![DCLopes](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DCLopes](https://fortran-lang.discourse.group/u/DCLopes)\
**Post date:** [April 27, 2024, 6:46pm UTC](https://fortran-lang.discourse.group/t/configuring-fpm-modern-fortran-fortls-on-vscode-issues/7912/7 "2024-04-27T18:46:10Z")

</div>

That one did the trick! Thanks!
