Skip to content

Commit b0c27ce

Browse files
machsixkrvajal
authored andcommitted
Fix linter not work on Windows/MinGW-x64 (#118)
In previous version, to make linter works on Windows, there are the following three requirements: 1. Install `MinGW-x64` version `gfortran` compiler. NOT MSYS2, NOT Cygwin. Only `MinGW-x64` can run natively on windows. You can install it by first install [mysys2](https://www.msys2.org/) and then run `pacman -Syu` and ` pacman -S mingw-w64-x86_64-toolchain`. 2. Add the `bin` directory to the `PATH` environment variable, for my case, it's `C:\msys64\mingw64\bin` 3. Add the path of `gfortran` to the `Gfortran Excutable`, for my case, it's `C:\msys64\mingw64\bin\gfortran.exe` This PR removes the second requirement since editing `PATH` globally can ruin other program. The fix extracts the path of `bin` directory of `gfortran` and adds it to the `PATH` of `child_process` Fix #116
1 parent b61d1d1 commit b0c27ce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/features/linter-provider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export default class FortranLintingProvider {
3737
...process.env,
3838
LC_ALL: 'C'
3939
};
40+
if (process.platform == 'win32') {
41+
// Windows needs to know the path of other tools
42+
if (!env.Path.includes(path.dirname(command))) {
43+
env.Path = `${path.dirname(command)}${path.delimiter}${env.Path}`;
44+
}
45+
}
4046
let childProcess = cp.spawn(command, argList, { cwd: filePath, env: env });
4147

4248
if (childProcess.pid) {

0 commit comments

Comments
 (0)