vscode-cmake-tools: Can not launch the target in new terminal

Brief Issue Summary

I use Cmake Tools “launch” to build and open the program in one go. it compiles then open a “Cmake/Launch” terminal where it trys to launch the program .

But something happened ,now after building the program doesn’t run anymore (or at least depending on the program build very inconsistently) from within the Cmake/Launch integrated terminal where as if I split that same terminal and run the program from that new powershell terminal it works

I noted that if in CMakeLists.txt i only add main.cpp as executable its ok, but depending on what else I add it then wont run.

image

BTW its not linked to #535 I believe

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.79.2",
  "cmtVersion": "1.14.33",
  "configurations": [
    {
      "folder": "c:\\msys64\\home\\SysErr\\old\\smartmap",
      "cmakeVersion": "3.22.0",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "C:/msys64/mingw64/bin/gcc.exe",
        "CXX": "C:/msys64/mingw64/bin/g++.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///c%3A/msys64/home/SysErr/old/smartmap/main.cpp"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/msys64/home/SysErr/old/smartmap/main.cpp",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/msys64/mingw64/bin/g++.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "-g"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "Test",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[extension] [7475] cmake.launchTarget started
[main] Building folder: smartmap Test
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build Test
[proc] Executing command: C:\msys64\mingw64\bin\cmake.EXE --build c:/msys64/home/SysErr/old/smartmap/build --config Debug --target Test --
[proc]   with environment: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\SysErr\\AppData\\Roaming","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","COMPUTERNAME":"SYSTEM","ComSpec":"C:\\Windows\\system32\\cmd.exe","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\SysErr","LOCALAPPDATA":"C:\\Users\\SysErr\\AppData\\Local","LOGONSERVER":"\\\\SYSTEM","NUMBER_OF_PROCESSORS":"12","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 158 Stepping 10, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"9e0a","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules","PUBLIC":"C:\\Users\\Public","Path":"C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Users\\SysErr\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\Neovim\\bin;C:\\msys64\\mingw64\\bin;C:\\msys64\\mingw64\\bin","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SESSIONNAME":"Console","SystemDrive":"C:","SystemRoot":"C:\\Windows","TEMP":"C:\\Users\\SysErr\\AppData\\Local\\Temp","TMP":"C:\\Users\\SysErr\\AppData\\Local\\Temp","USERDOMAIN":"SYSTEM","USERDOMAIN_ROAMINGPROFILE":"SYSTEM","USERNAME":"SysErr","USERPROFILE":"C:\\Users\\SysErr","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\SysErr\\AppData\\Roaming\\Code\\CachedData\\695af097c7bd098fbf017ce3ac85e09bbc5dda06","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Users\\SysErr\\AppData\\Local\\Programs\\Microsoft VS Code","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\7efa7c941ce40a3dcf2eecb791ae2089-1.79.2-main-sock","VSCODE_L10N_BUNDLE_LOCATION":"","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"fr-fr\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"6472","windir":"C:\\Windows","CMT_MINGW_PATH":"C:\\msys64\\mingw64\\bin","NINJA_STATUS":"[%s/%t %p :: %e] "}
[build] ninja: no work to do.
[driver] Build completed: 00:00:00.064
[cmakefileapi-parser] Read reply folder: c:\msys64\home\SysErr\old\smartmap\build\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: ["cache-v2-c4f31b39a2a153990b33.json","cmakeFiles-v1-792f6ace861c805dacd5.json","codemodel-v2-3ba847330bd621f53863.json","directory-.-Debug-d0094a50bb2071803777.json","index-2023-06-27T09-09-55-0503.json","target-Test-Debug-3124bb2da009c5b13aeb.json","toolchains-v1-99b97b9bc1254da480bd.json"]
[build] Build finished with exit code 0
[cache] Reading CMake cache file c:/msys64/home/SysErr/old/smartmap/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [7475] cmake.launchTarget finished (returned {"name":"CMake/Launch - Test","processId":{},"creationOptions":{"name":"CMake/Launch - Test","env":{"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\SysErr\\AppData\\Roaming","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","COMPUTERNAME":"SYSTEM","ComSpec":"C:\\Windows\\system32\\cmd.exe","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\SysErr","LOCALAPPDATA":"C:\\Users\\SysErr\\AppData\\Local","LOGONSERVER":"\\\\SYSTEM","NUMBER_OF_PROCESSORS":"12","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 158 Stepping 10, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"9e0a","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules","PUBLIC":"C:\\Users\\Public","Path":"C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Users\\SysErr\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\Neovim\\bin;C:\\msys64\\mingw64\\bin;C:\\msys64\\mingw64\\bin","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SESSIONNAME":"Console","SystemDrive":"C:","SystemRoot":"C:\\Windows","TEMP":"C:\\Users\\SysErr\\AppData\\Local\\Temp","TMP":"C:\\Users\\SysErr\\AppData\\Local\\Temp","USERDOMAIN":"SYSTEM","USERDOMAIN_ROAMINGPROFILE":"SYSTEM","USERNAME":"SysErr","USERPROFILE":"C:\\Users\\SysErr","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\SysErr\\AppData\\Roaming\\Code\\CachedData\\695af097c7bd098fbf017ce3ac85e09bbc5dda06","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Users\\SysErr\\AppData\\Local\\Programs\\Microsoft VS Code","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\7efa7c941ce40a3dcf2eecb791ae2089-1.79.2-main-sock","VSCODE_L10N_BUNDLE_LOCATION":"","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"fr-fr\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"6472","windir":"C:\\Windows","CMT_MINGW_PATH":"C:\\msys64\\mingw64\\bin","_CMAKE_TOOLS_LAUNCH_TERMINAL_TARGET_NAME":"Test","_CMAKE_TOOLS_LAUNCH_TERMINAL_PATH":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"},"cwd":"C:\\msys64\\home\\SysErr\\old\\smartmap\\build"},"state":{"isInteractedWith":true},"dimensions":{"columns":263,"rows":38}})

Additional Information

the only thing I can see here that when creating the terminal it uses the flags (if that is the place to look?):

private launchTerminalTargetName = '_CMAKE_TOOLS_LAUNCH_TERMINAL_TARGET_NAME';
private launchTerminalPath = '_CMAKE_TOOLS_LAUNCH_TERMINAL_PATH';

image

UPDATE: to answer to @benmcmorran I indeed use MSYS2 that I installed thru installer … I use mingw64

and one of thje failcase if when I add in the executables “include/vendor/RectangleBinPack/GuillotineBinPack.cpp” for instance

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25 (11 by maintainers)

Most upvoted comments

@snehara99 It can be considered resolved since the environment variable ’PATH‘ is fully preserved. However, the content of the ‘PATH’ may be duplicated.

Hi,

This is my vscode version:

  • Windows 11 Pro for Workstations 22H2
  • VS Code v1.83.1
  • CMake Tools v1.16.13

I’m using the newest MSYS2 UCRT toolchain. Screenshot 2023-10-13 094920

This is my demo project with this kind of issue: 2.2_Add2.zip

Screenshot 2023-10-13 094746

I have a similar problem. If I launch the program using the bottom launch button (the small triangle symbol), the program will exit without any output. But if I launch the program in the terminal created by myself, the program will run properly.

The difference of the two terminal is environment variable, which could be displayed by command echo $env:path. In the terminal created by the plugin, which named like “CMake/Launch - xxx”, the environment variable is strange, it has two mingw and the sequence is wrong.

I have to switch to version v1.13.45 to avoid the problem.

Thanks for the report! You mentioned that a simple project with main.cpp works, but it starts to fail when you add additional files. If possible, can you provide an example of an additional file that makes it fail? Also, can you confirm that you’re running in a MSYS environment and tell us how you installed MSYS?