Auto format with modern FORTRAN extension does not work

As the title says, selecting “format document” from the right click menu only gives a popup saying something like “installing findent” but with no real effect.

findent is actually installed, and works correctly in CLI. The path is specified in the settings:

{
    "fortran.formatting.path": "/users/myuid/.local/bin/findent",
    "fortran.fortls.path": "/users/myuid/.local/bin/fortls",
}

Here are the relevant log entries:

2023-02-15 19:43:17.608 [error] [fortran-lang.linter-gfortran] provider FAILED
2023-02-15 19:43:17.609 [error] Error: spawn ENOTDIR
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:700:9)
at /users/myuid/.vscode-server/extensions/fortran-lang.linter-gfortran-3.2.0/dist/extension.js:2:171754
at new Promise ()
at n.spawnAsPromise (/users/myuid/.vscode-server/extensions/fortran-lang.linter-gfortran-3.2.0/dist/extension.js:2:171709)
at n.FortranFormattingProvider.doFormatFindent (/users/myuid/.vscode-server/extensions/fortran-lang.linter-gfortran-3.2.0/dist/extension.js:2:153880)
at n.FortranFormattingProvider.provideDocumentFormattingEdits (/users/myuid/.vscode-server/extensions/fortran-lang.linter-gfortran-3.2.0/dist/extension.js:2:152470)
at z.provideDocumentFormattingEdits (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:98:39761)
at /users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:98:61932
at le.s (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:98:56737)
at le.$provideDocumentFormattingEdits (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:98:61919)
at l.N (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:106:11239)
at l.M (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:106:10957)
at l.H (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:106:10005)
at l.G (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:106:9022)
at /users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:106:7810
at f.invoke (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
at g.deliver (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
at d.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
at p.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:14861)
at /users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:122:15815
at f.invoke (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
at g.deliver (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
at d.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
at p.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:14861)
at t.E (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:18927)
at /users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:16915
at f.invoke (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
at g.deliver (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
at d.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
at h.acceptChunk (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:12592)
at /users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:11879
at f.invoke (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:145)
at g.deliver (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:2029)
at d.fire (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:63:1667)
at d.t (/users/myuid/.vscode-server/bin/441438abd1ac652551dbe4d408dfcec8a499b8bf/out/vs/workbench/api/node/extensionHostProcess.js:72:28518)

if it matters, this is a remote host (via remote-ssh extension) in HPC environment.

Has anyone seen this before?

Sorry this post got lost in the Discourse and I forgot to answer. For specifying a formatter, you should not include the name of the formatter, just the the location of where the binary is located, see GitHub - fortran-lang/vscode-fortran-support: Fortran language support for Visual Studio Code.

e.g.

{
  "fortran.formatting.path": "./custom/path/venv/bin"
}

Hope this helps

Thank you!
I find it to be a little confusing that for fortls you include the binary’s name.

You are right, it’s not ideal but we are trying to make swapping between formatters easier, while not allowing for arbitrary executables to run.

This option has long been bothering me too, so I might just change it.

I would like to ask a similar question. When using the Modern Fortran plugin and findent for code formatting, it has no effect. I have already installed findent and configured it to format upon saving. Additionally, I do not see an option to format the document when I right-click. Here is part of my user settings file:

{
  "workbench.settings.applyToAllProfiles": [
    "editor.formatOnSave"
  ],
  "editor.formatOnSave": true,
  "fortran.formatting.path": "C:\\Users\\86130\\AppData\\Local\\Programs\\Python\\Python311\\bin",
  "fortran.formatting.findentArgs": [
    "-i4"
  ],
}

Could you help me?

I have identified the issue. In addition to installing Modern Fortran, I also installed another plugin called
fortran. However, I didn’t realize that these two plugins actually provide the same functionality. This happened because I came across some wrong tutorials when I was learning how to configure debugging files. It seems to be a very basic mistake.
Anyway, thanks for the assistance from this discussion.