105

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?

2

16 Answers 16

104

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

7
  • 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à Commented Sep 27, 2019 at 8:10
  • 8
    This doesn't work for me. It's saying Property is not allowed for justMyCode (I'm using visual studio code 2018)
    – cluis92
    Commented Aug 26, 2020 at 15:39
  • 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 (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
    Commented Jun 22, 2021 at 18:38
  • 1
    This configuration can only be used by the test debugging commands. "request": "test" is deprecated use "purpose" instead.
    – y_159
    Commented Feb 10, 2022 at 21:41
  • 3
    @cluis92, the editor says is not allowed, but it works in fact. Commented Aug 30, 2022 at 8:04
71

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.)

7
  • 3
    That's for Visual Studio full, not Visual Studio code
    – Revolt64
    Commented Oct 25, 2018 at 3:01
  • 1
    @Revolt64 Sorry, I misread that. I edited my answer for Visual Studio Code.
    – Geshode
    Commented Oct 25, 2018 at 3: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
    Commented Oct 25, 2018 at 14:05
  • justMyCode is not a valid configuration for launch.json in vscode Commented Aug 23, 2019 at 18:43
  • In order to avoid redundant exceptions previous to the desired breakpoint, disable Raised Exceptions checkbox
    – cpinamtz
    Commented Mar 22, 2020 at 13:49
46

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

7
  • 4
    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
    Commented Sep 17, 2021 at 9:00
  • A specially thanks for mentioned: "version": "0.2.0"!!! Without that setting. I've fallen into that issue: github.com/microsoft/vscode-python/issues/14381 Commented Dec 23, 2021 at 19:45
  • Still not resolved with this solution too.
    – y_159
    Commented Feb 10, 2022 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) Commented Feb 11, 2022 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) Commented Feb 14, 2022 at 16:59
13

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!

1
  • 5
    What in the actual heck. That worked. GRRRR Commented Jan 31, 2023 at 3:27
7

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

1
  • 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" Commented Jul 13, 2021 at 9:49
4

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.

4

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

4

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.

1
  • This comment rocks! Just recently VSCode is issuing a warning here This configuration will be deprecated soon. Please replace "python" with "debugpy" to use the new Python Debugger extension.(2), so the type should be replaced with debugpy, as below: json { "name": "Python: Debug Unit Tests", "type": "debugpy", "request": "launch", "purpose": ["debug-test"], "console": "integratedTerminal", "justMyCode": false, }
    – Krzysztow
    Commented Sep 18 at 2:13
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"
  ]
1

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:

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,
    }
],
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.

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}",
        }
    ],
},
0

One can set

{
    ...
    "debugpy.debugJustMyCode": false
    "jupyter.debugJustMyCode": false // for jupyter cells
}

in settings.json in one or both of the User and Workspace settings files. It also works for jupyter cells.

This is the most reliable and consistent solution for me.

-1

The following worked for me:

  1. Set "justMyCode": false
  2. Then press debug button dropdown and select "Debug using launch.json"
2
  • This is just repeating other answers. Commented Jul 31 at 23:16
  • @GinoMempin in fact none of the answers worked for me. Instead this did
    – Imtiaz U
    Commented Aug 4 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.