pythonunit-testingvisual-studio-codedebugging

Cannot debug test case in VS Code: Found duplicate in "env": PATH


I am using VS Code for developing in Python. I have been able to debug single test cases from the test module, which is very practical. Since recently, it no longer works. After a short waiting time, a dialog pops up: "Invalid message: Found duplicate in "env": PATH." with the buttons "Open launch.json" and "Cancel". Opening launch.json does not help, since I don't manipulate PATH there. I also did not edit PATH recently (and the message seems to point not to a wrong value in PATH, but to PATH being set multiple times).

I tried to see the duplicate PATH myself, but failed: Both echo ${env:PATH} at the console and os.environ in Python will only give a single PATH variable - as already implied by the used data structure.

I tried applying this SO answer. It does neither relate directly to VS Code, nor to duplicate PATH variables, but to duplicates in PATH, but it was the closest I found on here. It didn't work.


Solution

  • You can install different versions of the Python plugin (to whom it may concern: if this works unsatisfactorily, it may be because you have multiple instances of VS Code running). You will note:

    1. 2023.4.1 is the latest known stable version that works
    2. 2023.6.0 does not work
    3. v2023.7.11011538 (latest) works

    It seems it's an issue in the latest stable version the VS Code team have solved in the meanwhile.