Vscode-cpptools: debugger gives newtonsoft.json error on linux

Created on 27 Jan 2020  Â·  4Comments  Â·  Source: microsoft/vscode-cpptools

I am trying to set up a debugger for my C++ project on arch Linux.

My launch.json looks like this:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/path/to/executable",
            "args":
            [
                …
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment":
            [{
                …
            }],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

However, when I try to start the debugging, I get a popup window with a long error message about newtonsoft.json exceptions (in two parts because it's so long):
code_debug_error_upper
code_debug_error_lower

Newtonsoft.json seems to be installed on the system and VS Code seems to find it (otherwise, I guess, it couldn't throw an exception...), though I have no experience with it.

$ code --version
1.41.1
26076a4de974ead31f97692a0d32f90d735645c0
x64

$ uname -orm
5.4.15-arch1-1 x86_64 GNU/Linux
debugger

Most helpful comment

Since it looks like you omitted the actual block, I can't for sure say why its happening.

The environment block was there (I put in an ellipsis for the code block here), I just interpreted the formatting incorrectly.
I set it up like

environment: [{
    "root_dir": "/root/dir/", 
    "other_dir": "/other/dir/"
}]

instead of

environment: [
    {"name": "root_dir", "value": "/root/dir/"},
    {"name": "other_dir", "value": "/other/dir/"}
]

I changed it and it is starting now.
Maybe the documentation can be a bit more verbatim about this.

Thanks for your help!
cheers!

All 4 comments

The error seems to be saying that NewtonSoft can't parse your environment array due to it not finding the Name object.

Here is the format for how environment is supposed to be specified.

Since it looks like you omitted the actual block, I can't for sure say why its happening.

Since it looks like you omitted the actual block, I can't for sure say why its happening.

The environment block was there (I put in an ellipsis for the code block here), I just interpreted the formatting incorrectly.
I set it up like

environment: [{
    "root_dir": "/root/dir/", 
    "other_dir": "/other/dir/"
}]

instead of

environment: [
    {"name": "root_dir", "value": "/root/dir/"},
    {"name": "other_dir", "value": "/other/dir/"}
]

I changed it and it is starting now.
Maybe the documentation can be a bit more verbatim about this.

Thanks for your help!
cheers!

This page shows the wrong way to do this!!!

https://code.visualstudio.com/docs/cpp/launch-json-reference

Would seem like a good thing to fix.

Was this page helpful?
0 / 5 - 0 ratings