microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 451 forks source link

Launch Target doesn't initialise the shell as per the user's config #3921

Open ic2000 opened 3 months ago

ic2000 commented 3 months ago

Brief Issue Summary

In my case, I'm using MSYS2 for my default terminal:

    "terminal.integrated.profiles.windows": {
        "MSYS2": {
            "path": "C:/Tools/msys64/usr/bin/bash.exe",
            "label": "MSYS2",
            "args": ["--login", "-i"],
            "env": {
                "MSYSTEM": "MSYS2",
                "CHERE_INVOKING": "1",
                "MSYS2_PATH_TYPE": "inherit"
            }
        },
    },
    "terminal.integrated.defaultProfile.windows": "MSYS2",

I rely on these arguments in order to pick the correct MSYS shell and to bring over the path variables (especially important for running my program after compiling, as without "inherit" being defined the path starts from a flash slate).

It seems like CMake Tools only retrieves and utilises the shell path, ignoring the rest of the user's configuration for that shell. I haven't found any means to configure this and it essentially renders the Launch Target feature useless for anyone who has a non-trivial shell setup.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

The terminal instance created by Launch Target:

ic2000@Win11 MSYS ~
$ "C:/Users/ic2000/Documents/Projects/Test/build/Release/src/test.exe"
C:/Users/ic2000/Documents/Projects/Test/build/Release/src/test.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

The terminal instance created by VS Code, properly utilising my terminal configuration:

ic2000@Win11 MSYS2 ~
$ "C:/Users/ic2000/Documents/Projects/Test/build/Release/src/test.exe"
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)

https://github.com/microsoft/vscode-cmake-tools/commit/d9557e68f4b08983414ef45ea08caa8523c68f28 is how I've personally got around this for the meantime.

Evelyn-001 commented 2 months ago

@ic2000, thanks for reporting this issue. Today we try to repro your issue using a simple project, and after building the project, launch the target in the terminal instance(MSYS2). we find that the target could launch successfully. Please see the below picture. For further investigation, could you please share us a demo project with clear repro steps? We are looking forward to hearing from you. Thanks. ENV: VS code: 1.91.1 CMake Tool: v1.18.43 image

starball5 commented 2 months ago

what if you use the automation profile setting instead? semi-related: #3756

Evelyn-001 commented 2 months ago

@starball5, thanks for your reply. Today we try to repro your issue with automation profile setting, and after building the project, launch the target in the terminal instance(Powershell). we find that the target could launch successfully. Please see the below picture. Thanks. ENV: VS code: 1.91.1 CMake Tool: v1.18.43 image