Skip to content

Python debug breakpoint not working on (base) #710

Closed

Description

Discussed in microsoft/vscode-python#17152

Originally posted by bynkook August 29, 2021
VS Code Version: 1.59.1 (user setup)
OS Version: Windows 10 19H2

Steps to Reproduce:
Install Miniconda3
Install Vscode, python extension, activate conda (base)
Initial settings with default launch.json, run code in the screenshot with breakpoint. the breakpoint is not working
JustMyCode : false is tested. Not working.
Same test on two different clean machine which never installed python and vscode before.
210827 vscode test

the debug works fine when a virtual environment create with command such as "conda create -n venv python=3.9.6" Apparently it seems the trouble happens when user is activated (base) without any reason.
210827 vscode test(2)

Question : Is this a normal situation intended?

Activity

  1. fabioz commented on Aug 30, 2021

    @fabioz
    Collaborator

    Can you provide the logs (for both the case where it works and where it doesn't work)?

    i.e.:

    • Open VS Code
    • Select the command Extensions: Open Extensions Folder
    • Locate the Python extension directory, typically of the form ms-python.python-2021.*.****
    • In that directory ensure you do not have any debug*.log files, if you do, please delete them
    • Go back into VS Code and modify your launch.json to add the setting "logToFile": true, see below:
    {
        "name": "Python: Current File (Integrated Terminal)",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal",
        "logToFile": true
    }
    
    • Start debugging
    • When done, go back into the extension directory and upload the debug*.log files into this GitHub issue.
  2. int19h commented on Aug 30, 2021

    @int19h
    Contributor

    The path to the script being debugged is under C:\Users\...\Miniconda, which is also the base prefix of the Python interpreter if you use base. IIRC that will make your script be treated as if it were a part of the standard library - i.e. it won't be considered "your code" if you have Just My Code enabled (which is true by default). Try setting "justMyCode": false and see if that helps.

    (If it is indeed the problem, I would recommend moving your scripts out of that folder. In general, it should only contain the Python implementation, its standard library, and any global packages that you have installed via conda or pip.)

  3. bynkook commented on Aug 31, 2021

    @bynkook

    The path to the script being debugged is under C:\Users\...\Miniconda, which is also the base prefix of the Python interpreter if you use base. IIRC that will make your script be treated as if it were a part of the standard library - i.e. it won't be considered "your code" if you have Just My Code enabled (which is true by default). Try setting "justMyCode": false and see if that helps.

    (If it is indeed the problem, I would recommend moving your scripts out of that folder. In general, it should only contain the Python implementation, its standard library, and any global packages that you have installed via conda or pip.)

    As i mentioned, JustMyCode solution is not working.

  4. fabioz commented on Aug 31, 2021

    @fabioz
    Collaborator

    The logs are showing:

    "justMyCode": true,

    and thus:

    sending cmd (http_json) --> CMD_RETURN {"type": "response", "request_seq": 8, "success": true, "command": "setBreakpoints", "body": {"breakpoints": [{"verified": false, "message": "Breakpoint in file excluded by filters.\nNote: may be excluded because of \"justMyCode\" option (default == true).Try setting \"justMyCode\": false in the debug configuration (e.g., launch.json).\n", "source": {"name": "0.py", "path": "c:\\Users\\bk3.lee\\Miniconda3\\userspace\\0.py"}, "line": 1}]}, "seq": 18, "pydevd_cmd_id": 502}

    Can you create a launch with "justMyCode": false, and resend the logs where it doesn't work with that launch configuration?

  5. brettcannon commented on Aug 31, 2021

    @brettcannon
    MemberAuthor

    bynkook for the log request.

  6. bynkook commented on Sep 1, 2021

    @bynkook

    well i can not believe such simple 2 lined python code is requiring for a unprofessional user to modify internal configuration to set a breakpoint of debugging. anyway i attached the log files as instructed. I want to highlight that JustMyCode:False did not resolve the issue.

    debugger.vscode_62a670aa-580e-478f-aa0c-e718e6bf4c9e.log
    debugpy.adapter-18436.log
    debugpy.launcher-8812.log
    debugpy.pydevd.10208.log
    debugpy.server-10208.log

  7. int19h commented on Sep 1, 2021

    @int19h
    Contributor

    Debug configuration keys are case-sensitive; you set "JustMyCode", but the actual key name is "justMyCode".

    (Note that you wouldn't have to do this if you didn't keep your user code under C:\Users\...\Miniconda - then it would "just work".)

  8. bynkook commented on Sep 1, 2021

    @bynkook

    The path to the script being debugged is under C:\Users\...\Miniconda, which is also the base prefix of the Python interpreter if you use base. IIRC that will make your script be treated as if it were a part of the standard library - i.e. it won't be considered "your code" if you have Just My Code enabled (which is true by default). Try setting "justMyCode": false and see if that helps.

    (If it is indeed the problem, I would recommend moving your scripts out of that folder. In general, it should only contain the Python implementation, its standard library, and any global packages that you have installed via conda or pip.)

    Indeed all my .py files are under c:\Users[user]\Miniconda3\userspace, the sub folder i created.

  9. bynkook commented on Sep 1, 2021

    @bynkook

    Debug configuration keys are case-sensitive; you set "JustMyCode", but the actual key name is "justMyCode".

    (Note that you wouldn't have to do this if you didn't keep your user code under C:\Users\...\Miniconda - then it would "just work".)

    Now I can confirm the "justMyCode": false solution is working. Now I think outstanding issue is how to figure out basically why 2 line 'hello world' example is not debugging under conda (base) without adding the magic word.

  10. bynkook commented on Sep 7, 2021

    @bynkook

    Windows 10 19H2
    Miniconda3 (3.9.7)
    Vscode 1.59.1 portable
    Python Extension v2021.9.1191016588

    /conda create -n venv
    /conda activate venv

    After these, a breakpoint assigned, press F5, the terminal says it went back to (base) envionment and breakpoint not working.

    210907-vscode-debug

    debugger.vscode_3a66d6e3-9ba3-43eb-9a15-a2b6c30a7069.log
    debugpy.adapter-12256.log
    debugpy.launcher-17388.log
    debugpy.pydevd.6456.log
    debugpy.server-6456.log

  11. fabioz commented on Sep 7, 2021

    @fabioz
    Collaborator

    This seems to be because of "justMyCode": true instead of "justMyCode": false in the launch configuration.

  12. bynkook commented on Sep 7, 2021

    @bynkook

    This seems to be because of "justMyCode": true instead of "justMyCode": false in the launch configuration.

    Do you really think the 2 line Hello World code is requiring custom modification to settings for a simple debugging? Is it intended?

  13. fabioz commented on Sep 7, 2021

    @fabioz
    Collaborator

    This seems to be because of "justMyCode": true instead of "justMyCode": false in the launch configuration.

    Do you really think the 2 line Hello World code is requiring custom modification to settings for a simple debugging? Is it intended?

    So far, yes, it's intended... You're having problems because you're placing files inside of the directories reserved for conda, which is usually only meant for library directories, whereas most don't have problems because they create project files in directories that are not inside of conda.

    I agree that having justMyCode be false by default would actually fix your problem, but there are arguments for having it as true by default (as it is now) too.

    Your case could be supported if we implemented: #581 (but it's still not done and given other issues that still hasn't become a priority, so, there's no due date on it).

    The simplest solution for your use case it probably moving your project files to a directory that's not considered a library directory (i.e.: move it out of the conda directories).

    p.s.: closing issue as things are happening as intended.

  14. fabioz commented on Sep 7, 2021

    @fabioz
    Collaborator

    p.s.: Feel free to +1 #581 if you feel that support is interesting for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions