I can't run fortran code with VS Code

This only occurs when trying it through VS code, when I run it on the command line, it works on fine.

1 Like

The problem is not VS Code. You are executing the command from a “PowerShell” (PS) terminal which is slightly different to a “command line” terminal. It is possible that within the PS terminal your installation of gnu compilers is not visible.

If you see to the right of the console panel, you’ll see " > powershell +" and a small arrow downwards. Click on the arrow and it enables you to open different kind of terminals. You’ll see also the “command line”. You can use that as well directly within the VS Code workspace. Then you can try and check why the gnu compilers are not directly visible perse from PS.

The problem seems to be that gfortran is not in your PATH. If you are on Windows and installed gfortran from MSYS2, the environment variables are not always updated and you should add the folder where gfortran seats manually to your PATH variables.

Don’t forget to restart vscode to get the updated variables.

1 Like