83

When starting my project in the debugger (C# .NET Core), it states it's debugging "just my code".

I want to also debug the libraries, and can't see a setting to disable this anywhere in VSCode.

Is it possible to disable?

Revolt64
  • 941
  • 1
  • 6
  • 5
  • Do you have a skipFiles entry in your launch config? That is how you would skip over vendor code for example. See https://stackoverflow.com/questions/48620826/is-it-possible-to-blackbox-vendor-code-when-using-vscodes-node-debugger/48621036#48621036. Perhaps you have a skipfiles entry you could delete or modify. Does an extension set this or a similar value? – Mark Oct 25 '18 at 03:25

14 Answers14

83

Just adding "justMyCode": false to launch.json doesn't work. You need to add a separate config in launch.json like below. FYI each {} represents a config.

"configurations": [
        {
           .... # existing config
        },
        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false,
        }
    ]

As pointed out in here

Tenzin -
  • 947
  • 6
  • 8
  • 1
    Thank you! I had this issue. I put just my code "false" but I couldn't see frameworks libraries. So I changed the launch configuration as u said et voilà – Shil Nevado Sep 27 '19 at 08:10
  • 6
    This doesn't work for me. It's saying **Property is not allowed** for justMyCode (I'm using visual studio code 2018) – cluis92 Aug 26 '20 at 15:39
  • Hi there, I was using vscode 2019 during that time and It still works in vscode 2020. – Tenzin - Aug 28 '20 at 11:49
  • 4
    This was actually the answer to my own question, but it should be noted that it is specific to *testing* in a *python* project, while it looks like the OP was interested in debugging a *launch* of a *C#* project. Also, an [outstanding bug](https://github.com/microsoft/vscode-python/issues/14388) (at the time of writing) points out the ability to specify launch configs more globally (including the `justMyCode` option) via `settings.json`. (But the bug is that `justMyCode` is currently ignored in configurations for debugging unit tests.) – teichert Jun 22 '21 at 18:38
  • 1
    *This configuration can only be used by the test debugging commands. "request": "test" is deprecated use "purpose" instead.* – y_159 Feb 10 '22 at 21:41
  • 3
    @cluis92, the editor says is not allowed, but it works in fact. – PaleNeutron Aug 30 '22 at 08:04
  • Note that you can also define launch configs in the global `settings.json` or your workspace settings (`foo.code-workspace`). In this case, you won't have a `launch.json`. Currently, VSCode isn't picking up these special "debug configs" if they are defined outside launch.json, because of this [bug](https://github.com/microsoft/vscode-python/issues/17644) (issue 17644). So, you need to create a `launch.json` for this solution to work. I did that by removing my launch configs from my workspace settings, and then moving them into `launch.json`. – Hawkeye Parker Apr 05 '23 at 19:39
68

For this you need to change the launch.json file. Inside the launch.json file you have to set "justMyCode" to false.

As described here. (I was pointed to that link through this post on the Visual Studio Code site.)

Geshode
  • 3,600
  • 6
  • 18
  • 32
  • 2
    That's for Visual Studio full, not Visual Studio code – Revolt64 Oct 25 '18 at 03:01
  • @Revolt64 Sorry, I misread that. I edited my answer for Visual Studio Code. – Geshode Oct 25 '18 at 03:29
  • Edit: I had this in my launch.json file already, but due to it being at the bottom of the array and me accidentally adding a comma after the justMyCode line, it didn't work (that's what I get for a simple mistake). After removing the comma, it works. Thanks for the help! – Revolt64 Oct 25 '18 at 14:05
  • justMyCode is not a valid configuration for launch.json in vscode – Rayee Roded Aug 23 '19 at 18:43
  • In order to avoid redundant exceptions previous to the desired breakpoint, disable `Raised Exceptions` checkbox – cpinamtz Mar 22 '20 at 13:49
  • How can I do this for tests, ie, debugging Pytest tests in VS Code? – stefanbschneider Mar 07 '22 at 12:49
  • Ok, I found it here: https://code.visualstudio.com/docs/python/testing#_debug-tests Same as for other Python modules, just with extra `"purpose": ["debug-test"],` – stefanbschneider Mar 07 '22 at 12:52
38

VSCode 1.60 was complaining about the "request": "test" method suggested by others.

But I did have to add a new section below my existing configuration to get "justMyCode": false to work.

Here is what worked for me:

{
    // 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": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": [
                "blah",
                "whatever"
            ]
        },
        {
            "name": "Python: Debug Unit Tests",
            "type": "python",
            "request": "launch",
            "purpose": ["debug-test"],
            "console": "integratedTerminal",
            "justMyCode": false,
        }
    ]
}

The purpose addition appears to be important.

I found the correct approach documented here: https://code.visualstudio.com/docs/python/testing#_debug-tests

Dharman
  • 30,962
  • 25
  • 85
  • 135
warrens
  • 1,661
  • 18
  • 16
  • 3
    You know, you saved my evening today. :) I hope you have a great weekend. ("purpose" was exactly the configuration I was looking for just now - thanks!) – Rikki Sep 17 '21 at 09:00
  • A specially thanks for mentioned: "version": "0.2.0"!!! Without that setting. I've fallen into that issue: https://github.com/microsoft/vscode-python/issues/14381 – Vanya Usalko Dec 23 '21 at 19:45
  • Still not resolved with this solution too. – y_159 Feb 10 '22 at 22:09
  • @y_159 Could you make a note for the plugin version, which runs the tests? Cause I've struggled a lot with that sad issue) – Vanya Usalko Feb 11 '22 at 22:01
  • Perhaps its could help: - be sure that you use standard ms-python.python extension - don't forget check version flag in launch.json - and.... the configuration with "name": "Python: Debug Unit Tests", should be last) – Vanya Usalko Feb 14 '22 at 16:59
  • Ah, turns out it doesn't work if in **settings.json**, it has to be in **launch.json**, at least until https://github.com/microsoft/vscode-python/issues/18778 is fixed. (Doesn't help that the `Open 'launch.json'` command opens settings.json if you don't have a launch.json yet) – binaryfunt Apr 25 '22 at 11:43
  • "purpose" fixed it, thanks! And this solution is by the way the only one that worked for me. – mgross May 02 '22 at 09:24
9

I added the "justMyCode": false" setting to launch.json and it still didn't stop at breakpoints in external library code. What was even more confusing: It did work for once and then suddenly it didn't anymore.

Then I found out: If you are in the "Run and Debug (SHIFT+CMD+D)"-tab and select your configuration there and click the green triangle / "Start Debugging (F5)" it works! However, if I click "Debug Python File" in the upper right corner it does not stop in external library code!

kiko
  • 91
  • 1
  • 1
6

If you're specifically debugging Python unit tests, adding "justMyCode": "false" to your normal config won't do, you'll need to add another in your launch.json with "request": "test":

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false,
        },

Source: Github Microsoft/vscode-python Issue #7131

Dlean Jeans
  • 966
  • 1
  • 8
  • 23
  • 1
    This is kinda embarassing. I just realized my answer says almost the same as the one above. With my weary eyes when I posted, I couldn't make the difference between the my config and the one in that answer then wondered why it wouldn't work. So again I wanna emphasize the difference: `"request": "test"` – Dlean Jeans Jul 13 '21 at 09:49
3

If you are using vscode on mac, press shift+command+p, search for Open'launch.json' (if you don't have the file, create it in the .vscode directory in the project), open an editor you want, and add the following JSON object to the file :

{
            "name": "Python: Debug Unit Tests",
            "type": "python",
            "request": "launch",
            "purpose": ["debug-test"],
            "console": "integratedTerminal",
            "justMyCode": false,
}

Reopen your vscode and now you can put breakpoints on lines that are imported or you have not written.

Amir nazary
  • 384
  • 1
  • 7
3

As of 2022, VS Code no longer seems to have an “Open launch.json” shortcut in its command palette, but it still prompts you to edit launch.json to set "justMyCode" to false. The solution that worked for me was:

  • create a directory called .vscode in the root of the repository
  • create a file called launch.json in the .vscode directory
  • put this text in the file:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false,
        }
    ]
}

There will be an error message under the word "test" saying that "test" is not a valid value, and that "attach" would be valid. However, it doesn't work for me if I change "test" to "attach". If the "version" field isn't there, it doesn't work and VS Code raises an error saying launch.json is missing a field.

Matt
  • 169
  • 2
  • 3
3

This works for me, it's plain and simple. Basically,

  1. just set "justMyCode": false
  2. Then debug by pressing the debugger button at the bottom panel, instead of the top right corner.

Here's the main source. https://github.com/microsoft/debugpy/issues/795#issuecomment-1310846015

2

In the documenentation of Visual Studio Code they have a section "Skipping uninteresting code".

VS Code Node.js debugging has a feature to avoid source code that you don't want to step through (AKA 'Just My Code').
This feature can be enabled with the skipFiles attribute in your launch configuration. skipFiles is an array of glob patterns for script paths to skip.

In your launch.json file you have to add (or any other file you want to skip):

  "skipFiles": [
    "${workspaceFolder}/node_modules/**/*.js",
    "${workspaceFolder}/lib/**/*.js"
  ]
Hypenate
  • 1,907
  • 3
  • 22
  • 38
1

Recently, even I faced this issue where the VS code was not taking the latest launch.json (one with 'justMycode: false'). So, I had to perform the following steps.

  1. Instead of running a debugger from the Top right group menu of the editor, I ran it from below status bar as shown in the below picture

Click here to see the screenshot of the status bar

  1. Once clicked on this option a pop-up appears asking which launch.json you want to run your debugging with, as shown below.

Click here to see the screenshot of the pop-up menu

You can click on launch.json here to edit the configuration file and now the debugger opens with the selected launch.json and 'justtMycode:false' setting will be applied.

0

I added in the configurations part as below:

"configurations": [
    {
        "name": "Python: Curent File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal",
        "justMyCode": false,
    }
],
arjepak
  • 153
  • 1
  • 6
0

It took me a while to understand where the file needs to be and what exactly needs to be inside it. So here's what I've got for others to enjoy:

The launch.json file is not in the root of your project, it needs to be in .vscode/launch.json instead. And for new VSCode versions, once you open that file from that location, you can get warnings on issues in the file, and also automatically add sections to it.

For me, at the end the contents of the file is this:

{
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        },
    ]
}

This allows me to enter (F11) other libs when I run a custom code in debug mode for Python.

adrin
  • 4,511
  • 3
  • 34
  • 50
0

None of the fiddling with launch.json worked for me. I had to tick the "Allow setting breakpoints in any files" box in the Settings:

shamalaia
  • 2,282
  • 3
  • 23
  • 35
0

I merged the previous answers and the below setting works for me (vscode 1.75.0).

"launch": {
    "configurations": [
        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "launch",
            "purpose": "debug-test",
            "justMyCode": false,
            "program": "${file}",
        }
    ],
},
hgj
  • 1