Hi there,
I’m having the same problem on Debian Linux 12 with VS Code v-1.85.1, Modern Fortran Pre-Release v3.4.2024010301. fortls
is installed through pipx
and available in my $PATH
. The linter is disabled to try to isolate the issue below.
I tried specifying .fortls
as the local settings file in my *.code-workspace
file:
{
"folders": [
{
"path": "."
}
],
"settings": {
"cmake.automaticReconfigure": false,
"cmake.parallelJobs": 4,
"workbench.colorTheme": "Visual Studio Dark - C++",
"workbench.preferredDarkColorTheme": "Abyss",
"workbench.iconTheme": "vs-minimal",
"workbench.sideBar.location": "right",
"workbench.editor.closeOnFileDelete": false,
"window.density.editorTabHeight": "compact",
"files.autoSave": "onFocusChange",
"editor.wordWrap": "on",
"fortran.linter.compiler": "Disabled",
"fortran.linter.compilerPath": "",
"fortran.logging.level": "Debug",
"fortran.fortls.configure": "/home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls"
}
}
The workspace local .fortls
contains the following:
{
"lowercase_intrinsics": false,
"source_dirs": ["./**", "/usr/include"]
}
The system modules in /usr/include
are not found and I get the following error in the Fortran file Module "netcdf" not found in project
.
Here is the output of fortls
in VS Code:
[DEBUG - 17:32:45] [lsp.client] Language Server version: 2.13.0
[INFO - 17:32:45] [lsp.client] Initialising Language Server for workspace: file:///home/ziad/CoursesTutorials/Fortran/NetCDF
[INFO - 17:32:45] [lsp.client] Language Server arguments: --enable_code_actions --hover_signature --use_signature_help -c /home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls --nthreads=4 --notify_init --incremental_sync --sort_keywords --disable_autoupdate
[DEBUG - 17:32:45] [lsp.client] Language Server arguments:
[
"--enable_code_actions",
"--hover_signature",
"--use_signature_help",
"-c",
"/home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls",
"--nthreads=4",
"--notify_init",
"--incremental_sync",
"--sort_keywords",
"--disable_autoupdate"
]
[DEBUG - 17:32:45] [lsp.client] Language Server version: 2.13.0
[INFO - 17:32:45] fortls - Fortran Language Server 2.13.0 Initialized
[INFO - 17:32:45] fortls initialization complete
I also tried the other approach of specifying the include files in $workplace/.vscode/settings.json
:
{
"fortran.preferredCase": "uppercase",
"fortran.fortls.directories": ["./**","/usr/include"]
}
The module not found in project error in the Fortran file persists, and this is the fortls
output:
[INFO - 19:16:11] Extension Name: Modern Fortran
[INFO - 19:16:11] Extension Version: 3.4.0
[INFO - 19:16:11] Linter set to: "Disabled"
[INFO - 19:16:11] Formatter set to: "findent"
[INFO - 19:16:11] Autocomplete set to: "fortls"
[INFO - 19:16:11] Hover set to: "fortls"
[INFO - 19:16:11] Symbols set to: "fortls"
[DEBUG - 19:16:11] [lsp.client] Fortran Language Server -- constructor
[DEBUG - 19:16:11] [lsp.client] Language Server arguments:
[
"--enable_code_actions",
"--hover_signature",
"--use_signature_help",
"-c",
"/home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls",
"--nthreads=4",
"--notify_init",
"--incremental_sync",
"--sort_keywords",
"--disable_autoupdate"
]
[DEBUG - 19:16:11] [lsp.client] Language Server version: 2.13.0
[INFO - 19:16:11] [lsp.client] Initialising Language Server for workspace: file:///home/ziad/CoursesTutorials/Fortran/NetCDF
[INFO - 19:16:11] [lsp.client] Language Server arguments: --enable_code_actions --hover_signature --use_signature_help -c /home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls --nthreads=4 --notify_init --incremental_sync --sort_keywords --disable_autoupdate
[INFO - 19:16:11] fortls - Fortran Language Server 2.13.0 Initialized
[INFO - 19:16:11] fortls initialization complete
[DEBUG - 19:16:11] [lsp.client] Language Server arguments:
[
"--enable_code_actions",
"--hover_signature",
"--use_signature_help",
"-c",
"/home/ziad/CoursesTutorials/Fortran/NetCDF/.fortls",
"--nthreads=4",
"--notify_init",
"--incremental_sync",
"--sort_keywords",
"--disable_autoupdate"
]
[DEBUG - 19:16:11] [lsp.client] Language Server version: 2.13.0
I even tried adding the "source_dirs"
directly by adding them as entries in the Fortran > Fortls: Directories
option in the Modern Fortran extension settings. Same module error!
At my wits end here, and wondering if anyone knows how to fix this. I get the feeling I’m just one simple setting away…
Thanks