4

I continue to get this error when I attempt to debug a C++ program: can't launch program 'c:\Users\'my username'\Desktop\C++\'; setting the 'outDir' attribute might help

I have tried various combinations of syntax so that it would satisfy the condition, but I have had no success. I have spent hours trying to find the proper syntax and I have no idea what my problem is. I have had success with running JavaScript applications but they don't seem to require Source maps or the outDir field to be filled. I have the latest version of Visual Studio Code which is 0.7.10 and I have node downloaded and it seems to work fine. Here is a screenshot so you can get an idea of what I'm seeing. https://i.stack.imgur.com/XX0TB.png

Burt_Harris
  • 6,415
  • 2
  • 29
  • 64
Patrick18200
  • 41
  • 1
  • 3
  • I hope you find my answer responsive (if not timely.) I would like edit your question to eliminate the C++ specific parts. You OK with that? – Burt_Harris Jun 08 '17 at 22:37

2 Answers2

1

The VSCode message Cannot launch program ... setting the 'outDir' attribute might help can be somewhat misleading, even as recently as VSCode v1.12.2. I would take it with a grain of salt, it seems to simply mean there was a problem launching the application.

In my case, it was caused by a minor error in my launch.json file. I had:

        "type": "node",
        "request": "launch",
        "name": "Gulp",
        "program": "${workspaceRoot}/node_modules/gulp/bin",
        "sourceMaps": true,
        "outFiles": [
            "${workspaceRoot}/{lib,node_modules}/**/*.js",
            "!${workspaceRoot}/lib/tests/**/*.js"
        ]

I fixed it by changing one line:

        "program": "${workspaceRoot}/node_modules/gulp/bin/gulp",

Despite the message's attempt to be helpful, the outFiles property may not be necessary or helpful. Once I fixed the other problem, debugging seems to work fine without it.

Filed as a vscode issue 6/8/2017

Burt_Harris
  • 6,415
  • 2
  • 29
  • 64
  • I do not have the following folder `${workspaceRoot}/node_modules/gulp/bin`. Does the application suppose to run/debug without it or do I need to install grunt. Or grunt get installed automatically when installing `node`? I have an existing application. – phougatv Sep 28 '17 at 05:26
  • 1
    @barnes take a look in the `node_modules/.bin/` folder. Do you have `grunt` there? Are you trying to debug `grunt`? I the answer is yes to both, then set `"program": "${workspaceRoot}/node_modules/.bin/grunt"`. If you don't have `grunt` in `.bin` (the folder for node modules cross platform executables), then set `"program": "${workspaceRoot}/node_modules/grunt/bin/grunt.js"`. I hope you get the pattern. You need to locate the file you want to execute and set that in the `"program"` path. – dotnetCarpenter Dec 18 '17 at 11:14
  • @dotnetCarpenter Your help is much appreciated. Thanks – phougatv Dec 19 '17 at 09:33
-2

Only node and mono debugging are supported currently in VSCode. You should set the type in launch.json depending on what you want to debug. More details can be found here: https://code.visualstudio.com/Docs/editor/debugging

You get a weird error because you have sourceMaps: true in your launch.json.

Isidor Nikolic
  • 2,659
  • 2
  • 13
  • 11
  • 6
    If I set source maps to false, then I get another error saying something along the lines of "Failed to launch, maybe you should try enabling source maps". I can debug no problem with javascript, but I have yet to learn how to do so with other languages. And I have read that web page many times, I still don't what to do exactly. – Patrick18200 Aug 26 '15 at 22:47