Different environment of MSYS2 MINGW64 shell as standalone terminal and in Visual Studio Code

28 Views Asked by At

I am just trying to setup the programming language OCaml on my PC and the package manager there is called opam. I have followed these instructions: https://gist.github.com/mnxn/93009346c1bd56f387daf28413152179 and when I now start the MSYS2 MINGW64 shell (the blue one) and run

opam --version

it tells me that it is installed.

In my settings.json-File of Visual Studio Code, I have added the entry

 "terminal.integrated.profiles.windows": {
        
        "MSYS2 MinGW x64": {
            "path": "C:\\Software\\msys64\\usr\\bin\\bash.exe",
            "args": []
        }
}

so I can also start the terminal from there. However, if I run

opam --version 

from this Visual Studio Code-integraded terminal, it tells me bash : opam : command not found

Running

eval $(opam env)

is of no use.

When I run echo $PATH from the Visual Studio Code-Shell , it gives me

$ echo $PATH
/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/usr/bin:/mingw64/bin:/c/Users/imelf/AppData/Local/Microsoft/WindowsApps:/c/Software/Visual Studio Code/bin:/opt/bin:/opt/bin

When I run it from the MSYS2 MING64 shell, it gives me something different

$ echo $PATH
/home/imelf/.opam/ocaml-variants.4.10.0+mingw64c/bin:/mingw64/bin:/usr/local/s/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPow_perl:/bin/vendor_perl:/bin/core_perl:/opt/bin:/opt/bin

Why is there a difference? How do I need to integrate the MSYS2 MINGW 64 shell in Visual Studio Code so the PATH variable is the same as if I start the shell in standalone-mode?

0

There are 0 best solutions below