text:
Python Test Discovery Failed with no error message

Issue Type: Bug
I tried to run "Python: Discover Tests" but I got a message saying "Test discovery failed". I don't see any other information about what the failure was (for example no text is written to my terminal). According to the Python testing page when I click on the icon that says "Test discovery failed" it should provide more information. However, when I click on it it just searches for tests again and fails again. I don't know how to begin debugging because I don't see any other information other than the search has failed.
In my settings, I have "python.testing.pytestEnabled": true and don't have any other references to python.testing in it. I can run pytest directly from the command line and it works with no problem.
Extension version: 2020.4.76186
VS Code version: Code - Insiders 1.45.0-insider (0778354f3a6a2c21b7f738a5e6b02e2f1c765e73, 2020-04-27T05:39:56.514Z)
OS version: Darwin x64 19.3.0
Remote OS version: Linux x64 3.10.0-957.5.1.el7.x86_64

System Info

Item
Value

CPUs
Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz (8 x 2700)

GPU Status
2d_canvas: enabledflash_3d: enabledflash_stage3d: enabledflash_stage3d_baseline: enabledgpu_compositing: enabledmetal: disabled_offmultiple_raster_threads: enabled_onoop_rasterization: disabled_offprotected_video_decode: unavailable_offrasterization: enabledskia_renderer: disabled_off_okvideo_decode: enabledviz_display_compositor: enabled_onviz_hit_test_surface_layer: disabled_off_okwebgl: enabledwebgl2: enabled

Load (avg)
2, 2, 2

Memory (System)
16.00GB (0.41GB free)

Process Argv
-psn_0_6202858

Screen Reader
no

VM
0%

Item
Value

Remote
SSH: cpu103

OS
Linux x64 3.10.0-957.5.1.el7.x86_64

CPUs
Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz (4 x 2900)

Memory (System)
7.14GB (1.03GB free)

VM
0%

I kept poking around and managed to find an error message when I entered "pytest" into the command prompt

I went into the settings and wasn't sure what the error was but reset the python.testing.cwd so that my settings were:
“python.testing.pytestEnabled”: true,
“python.testing.cwd”: “”
I tried to discover tests again and it failed and didn't give an error. But after restarting I tried again and got this error:

Then I tried both:
“python.testing.cwd”: “${workspaceFolder}/tests”
and
“python.testing.cwd”: “${workspaceFolder}”
but now I'm back to it failing and giving this error:

In my user settings I have:
"python.testing.pytestEnabled": true,
"python.testing.cwd": "${workspaceFolder}"

And in my project settings I have:
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}

@juliussimonelli Can you check the extension directory ~/.vscode/extensions and see if there is more than one ms-python.python*. Delete all the older versions of ms-python. Uninstall and re-install the current version of the extension and reload.
Then load your project and see any command line where pytest is being run? Like this:

If this did not get pytest running, or if you still see discoverTests not found, let us know. If it did try discovery but it keeps failing, then try running the command that you get.
If you are not able to find the command that is being run, then try this, (modify the paths to match your project or system), and share the output.
/usr/bin/python3 ~/.vscode/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/projects/myproject/tests -s --cache-clear

I only see one version of ms-python:

I'll continue through your next steps though

I use this through the Remote SSH extension, so I have to reinstall all the extensions every time, so I've already reinstalled it a couple times and still had the problem. I did it just now as well and had the same issue. I also noticed another error today (before and after the restart) that I didn't have before (when I originally posted):

Previously I was able to go through the configure menu and select the test frame and file locations, but now I get this error.

Upon reading my project and looking in the OUTPUT tab and the Python extension, here is the only reference to pytest that I see:

@juliussimonelli Can you run that command line you are seeing from Output panel in the terminal and share output you get? We expect it to be JSON, but sometimes some of the pytest print something to output that breaks the json. So discovery might fail that way.
As for the configureTests or discoverTests errors. In the output panel, can you look at the various logs and see if there is any mention of these errors? You could also try looking at the console logs for vscode.

Yea, here's what I get:

@juliussimonelli in the output can you see "equivalent command" can you run that and see what you get. That is the command that we execute, if that does not return anything then pytest itself is not able to find. If it does return something, then please share the output.

This seems odd because I only pointed to the tests folder when I when through the Python: Configure Tests options, and it suggested that.

I just went through the Python: Configure Tests option again and that part worked. I still get the same error though.

Can you run it without the 'tests' at the end and see what you get?

Looks like pytest itself is not able to find tests. You will have to look into enabling pytest logging to figure out what is going on. Once pytest starts working the python extension should be able to pick the tests up.

@karthiknadig my mistake. I opened up a new terminal inside the container and was running the commands there. I didn't realize the output would be different than if I ran the commands inside the terminal within VSCode. Here is the output I got when running within VSCode (minus some deprecation warnings).
(tf2) [root@oicv3host combo_dataset]# /opt/conda/envs/tf2/bin/python -m pytest --collect-only --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
=============================================================== test session starts ===============================================================
platform linux -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.12.0
rootdir: /orbital/base/core/projects/combo_dataset
collecting ... 2020-05-01 20:13:45,052 Job=Unspecified Env=local Level=WARNING PID=5749 Thread=MainThread warnings.py:110  /opt/conda/envs/tf2/lib/python3.7/site-packages/osgeo/__init__.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

collecting 12 items                                                                                /store/vision_datasets
collected 13 items
<Package /orbital/base/core/projects/combo_dataset/tests/unit>
  <Module test_campaign_analyzer.py>
    <Function test_fill_keys[obj_types0-None-6-test_keys0-test_results0]>
    <Function test_fill_keys[obj_types1-ranking1-6-test_keys1-test_results1]>
    <Function test_fill_keys[obj_types2-None-3905-test_keys2-test_results2]>
    <Function test_create_all_keys[objs0-39-example_keys0]>
    <Function test_create_all_keys[objs1-6-example_keys1]>
    <Function test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]>
    <Function test_find_matches>
    <Function test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]>
    <Function test_get_df_combinations2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]>
    <Function test_get_df_combinations2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]>
    <Function test_get_df_combinations2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]>
    <Function test_get_df_combinations2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]>
  <Module test_campaign_extractor.py>
    <Function test_nothing>

============================================================== no tests ran in 3.04s ==============================================================
(tf2) [root@oicv3host combo_dataset]#

Can you try running this in the same terminal?
/opt/conda/envs/tf2/bin/python ~/.vscode/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests

(tf2) [root@oicv3host combo_dataset]# /opt/conda/envs/tf2/bin/python /root/.vscode-server-insiders/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
[{"rootid": ".", "root": "/orbital/base/core/projects/combo_dataset", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/unit", "kind": "folder", "name": "unit", "parentid": "./tests", "relpath": "./tests/unit"}, {"id": "./tests/unit/test_campaign_analyzer.py", "kind": "file", "name": "test_campaign_analyzer.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys", "kind": "function", "name": "test_create_all_keys", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_fill_keys", "kind": "function", "name": "test_fill_keys", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param", "kind": "function", "name": "test_find_matches_param", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test", "kind": "function", "name": "test_full_test", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2", "kind": "function", "name": "test_get_df_combinations2", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_extractor.py", "kind": "file", "name": "test_campaign_extractor.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_extractor.py"}], "tests": [{"id": "./tests/unit/test_campaign_analyzer.py::test_fill_keys[obj_types0-None-6-test_keys0-test_results0]", "name": "test_fill_keys[obj_types0-None-6-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:13", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_fill_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_fill_keys[obj_types1-ranking1-6-test_keys1-test_results1]", "name": "test_fill_keys[obj_types1-ranking1-6-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:13", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_fill_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_fill_keys[obj_types2-None-3905-test_keys2-test_results2]", "name": "test_fill_keys[obj_types2-None-3905-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:13", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_fill_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs0-39-example_keys0]", "name": "test_create_all_keys[objs0-39-example_keys0]", "source": "./tests/unit/test_campaign_analyzer.py:40", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs1-6-example_keys1]", "name": "test_create_all_keys[objs1-6-example_keys1]", "source": "./tests/unit/test_campaign_analyzer.py:40", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "name": "test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:52", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches", "name": "test_find_matches", "source": "./tests/unit/test_campaign_analyzer.py:70", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "name": "test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "source": "./tests/unit/test_campaign_analyzer.py:128", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_full_test"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "name": "test_get_df_combinations2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:152", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "name": "test_get_df_combinations2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:152", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "name": "test_get_df_combinations2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:152", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "name": "test_get_df_combinations2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "source": "./tests/unit/test_campaign_analyzer.py:152", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_df_combinations2"}, {"id": "./tests/unit/test_campaign_extractor.py::test_nothing", "name": "test_nothing", "source": "./tests/unit/test_campaign_extractor.py:15", "markers": [], "parentid": "./tests/unit/test_campaign_extractor.py"}]}]

whoa! I just tried to discover tests and it worked. I have no idea how that happened.

Nice. I guess I will close this for now. Please do let us know if this happens again. Hopefully we can find out what was happening.

@karthiknadig
this stopped working again. I got this error when I tried to discover tests:

Then I added this to my settings:
"python.testing.cwd": "tests"
Then I run this:
/opt/conda/envs/tf2/bin/python -m pytest --collect-only --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
Here's my result (minus deprecation warnings):
base) [root@oicv3host combo_dataset]# /opt/conda/envs/tf2/bin/python -m pytest --collect-only --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
================================================================ test session starts =================================================================
platform linux -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.12.0
rootdir: /orbital/base/core/projects/combo_dataset

collecting 12 items                                                                                /store/vision_datasets
collected 13 items
<Package /orbital/base/core/projects/combo_dataset/tests/unit>
  <Module test_campaign_analyzer.py>
    <Function test_create_mapping_dict[obj_types0-None-6-test_keys0-test_results0]>
    <Function test_create_mapping_dict[obj_types1-ranking1-6-test_keys1-test_results1]>
    <Function test_create_mapping_dict[obj_types2-None-3905-test_keys2-test_results2]>
    <Function test_create_all_keys[objs0-39-example_keys0]>
    <Function test_create_all_keys[objs1-6-example_keys1]>
    <Function test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]>
    <Function test_find_matches>
    <Function test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]>
    <Function test_get_object_matches2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]>
    <Function test_get_object_matches2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]>
    <Function test_get_object_matches2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]>
    <Function test_get_object_matches2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]>
  <Module test_campaign_extractor.py>
    <Function test_nothing>

=============================================================== no tests ran in 2.85s ================================================================
(base) [root@oicv3host combo_dataset]#

Then I try to Discover Tests and it fails again.
Then I run this (I'm not using the Insider version at the moment - the problem exists on both)
/opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
Here's the response I get:
(base) [root@oicv3host testing_tools]# /opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
equivalent command: /opt/conda/envs/tf2/bin/python -m pytest --collect-only --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
================================================================ test session starts =================================================================
platform linux -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.12.0
rootdir: /orbital/base/core/projects/combo_dataset
collected 0 items

=============================================================== no tests ran in 0.00s ================================================================
ERROR: file not found: tests

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
    parents, result = run(toolargs, **subargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 44, in discover
    raise Exception("pytest discovery failed (exit code {})".format(ec))
Exception: pytest discovery failed (exit code 4)

Then I changed my settings to
"python.testing.cwd": "${workspaceFolder}/tests"
and ran the above command again and got the same error. What should I try next?

@karthiknadig is there anything else I could try to find the bug?

@juliussimonelli when you ran the command manually it looks like you ran from testing_tools, which is in the extension directory. Can you run that command from the workspace folder?
/opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.4.76186/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests

@karthiknadig sorry about that. Here's the corrected version. The first time I ran it I got
(base) [root@oicv3host combo_dataset]# /opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
equivalent command: /opt/conda/envs/tf2/bin/python -m pytest --collect-only --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
================================================ test session starts =================================================
platform linux -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.12.0
rootdir: /orbital/base/core/projects/combo_dataset

collected 0 items / 2 errors

======================================================= ERRORS =======================================================
_______________________________ ERROR collecting tests/unit/test_campaign_analyzer.py ________________________________
tests/unit/test_campaign_analyzer.py:2: in <module>
    from combo_dataset.campaign_analyzer import (
campaign_analyzer.py:8: in <module>
    from combo_dataset.dataset_util import read_csv_clean
dataset_util.py:21: in <module>
    OI_root = join(os.environ['OI_VISION_DATA_ROOT'], 'VisionDatasets')
/opt/conda/envs/tf2/lib/python3.7/os.py:679: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'OI_VISION_DATA_ROOT'
_______________________________ ERROR collecting tests/unit/test_campaign_extractor.py _______________________________
tests/unit/test_campaign_extractor.py:2: in <module>
    from campaign_extractor import CampaignExtractor
campaign_extractor.py:19: in <module>
    print(os.environ["OI_VISION_DATA_ROOT"])
/opt/conda/envs/tf2/lib/python3.7/os.py:679: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'OI_VISION_DATA_ROOT'
============================================== short test summary info ===============================================
ERROR tests/unit/test_campaign_analyzer.py - KeyError: 'OI_VISION_DATA_ROOT'
ERROR tests/unit/test_campaign_extractor.py - KeyError: 'OI_VISION_DATA_ROOT'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================= 2 errors in 9.23s ==================================================

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
    parents, result = run(toolargs, **subargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 44, in discover
    raise Exception("pytest discovery failed (exit code {})".format(ec))
Exception: pytest discovery failed (exit code 2)

I get KeyError: 'OI_VISION_DATA_ROOT' because that's an environmental variable that I pass to the container in my docker run command and for some reason, it's available everywhere in the container except for within VSCode (and I haven't been able to figure out why, but that's a separate issue). So I ran export OI_VISION_DATA_ROOT='/store/vision_datasets' and tried again.
(base) [root@oicv3host combo_dataset]# /opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
[{"rootid": ".", "root": "/orbital/base/core/projects/combo_dataset", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/unit", "kind": "folder", "name": "unit", "parentid": "./tests", "relpath": "./tests/unit"}, {"id": "./tests/unit/test_campaign_analyzer.py", "kind": "file", "name": "test_campaign_analyzer.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys", "kind": "function", "name": "test_create_all_keys", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict", "kind": "function", "name": "test_create_mapping_dict", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param", "kind": "function", "name": "test_find_matches_param", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test", "kind": "function", "name": "test_full_test", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2", "kind": "function", "name": "test_get_object_matches2", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_extractor.py", "kind": "file", "name": "test_campaign_extractor.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_extractor.py"}], "tests": [{"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types0-None-6-test_keys0-test_results0]", "name": "test_create_mapping_dict[obj_types0-None-6-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types1-ranking1-6-test_keys1-test_results1]", "name": "test_create_mapping_dict[obj_types1-ranking1-6-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types2-None-3905-test_keys2-test_results2]", "name": "test_create_mapping_dict[obj_types2-None-3905-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs0-39-example_keys0]", "name": "test_create_all_keys[objs0-39-example_keys0]", "source": "./tests/unit/test_campaign_analyzer.py:34", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs1-6-example_keys1]", "name": "test_create_all_keys[objs1-6-example_keys1]", "source": "./tests/unit/test_campaign_analyzer.py:34", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "name": "test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:46", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches", "name": "test_find_matches", "source": "./tests/unit/test_campaign_analyzer.py:64", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "name": "test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "source": "./tests/unit/test_campaign_analyzer.py:122", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_full_test"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "name": "test_get_object_matches2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "name": "test_get_object_matches2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "name": "test_get_object_matches2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "name": "test_get_object_matches2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_extractor.py::test_nothing", "name": "test_nothing", "source": "./tests/unit/test_campaign_extractor.py:14", "markers": [], "parentid": "./tests/unit/test_campaign_extractor.py"}]}]

This looked promising so I clicked to discover tests again but it failed again and gave me this error

I went through all the Python settings and found two errors associated with the Python Preview extension.

So I uninstalled Python Preview and tried everything again. I got the same error so I went through all the settings and found more errors (by the way, is there a way to find these automatically?)

I don't know why I have those because I haven't touched those settings. Maybe it's associated with this bug report?
Anyway, it says the error is within the Python extension and I've been through it three times and am not seeing any error. That's where I'm at. Hopefully, something in the above was helpful to you :)

@juliussimonelli You may not be seeing OI_VISION_DATA_ROOT due to this VS Code setting  (this setting is not python specific) "terminal.integrated.inheritEnv": false. Check what is the value and toggle it and see if it helps. Note that you may have to reload after you toggle it.
Can you share what it shows in the test log? I mean for the case where you added the environment variable and then re-ran discovery. I am assuming that the discovery code is not getting the OI_VISION_DATA_ROOT, since it is only available in the terminal.
Another thing you could try is create a .env file in the root of your project and add OI_VISION_DATA_ROOT=value there, and see if that helps with discovery. If adding .env file solves this for you then we can try one more thing and see if this is a bug in VSCode itself where it is not picking up the envs.

"terminal.integrated.inheritEnv" was set to false so I toggled it to true and had the same problem.
After running /opt/conda/envs/tf2/bin/python /root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests I don't see anything in the Python Test Log. However, when I click to discover tests again it prints this out:
python /root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /orbital/base/core/projects/combo_dataset -s --cache-clear tests
Test Discovery failed:
Error: ============================= test session starts ==============================
platform linux -- Python 3.7.6, pytest-5.4.1, py-1.8.1, pluggy-0.12.0
rootdir: /orbital/base/core/projects/combo_dataset
collected 0 items

============================ no tests ran in 0.00s =============================
ERROR: file not found: tests

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
    parents, result = run(toolargs, **subargs)
  File "/root/.vscode-server/extensions/ms-python.python-2020.5.78807/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 44, in discover
    raise Exception("pytest discovery failed (exit code {})".format(ec))
Exception: pytest discovery failed (exit code 4)

I thought this might be associated with the "python.testing.cwd" setting, so I tried a bunch of different things but the output was the same. I tried: "${workspaceFolder}/", "${workspaceFolder}/tests", "${workspaceFolder}/tests/", "${workspaceFolder}/tests/unit", "/full/path/to/root_dir/tests", etc. Also, I found that if I went through the Configure Tests process it didn't actually change the value of this setting like I had expected. So if I have "python.testing.cwd": "/full/path/to/root_dir" and I go through the Python: Configure Tests process and select the test folder, it doesn't change it back to "${workspaceFolder}/tests". (Maybe it's not supposed to, that's just what I thought it did).
I also created a .env file in the root of my workspace with the single line: OI_VISION_DATA_ROOT='/store/vision_datasets'. I tried to discover the test cases again but had the same problem. It wasn't clear to me if the .env file was actually being read or not (no discernable output that I saw).

@karthiknadig that was the problem. The test discovery failed because it couldn't find that environment variable. Once I created a .env file with the line OI_VISION_DATA_ROOT=/store/vision_datasets (note NOT with single quotes like I did above) it fixed it immediately. And when I comment that line out it breaks again. Thanks so much for all your help.

@uliussimonelli This is fantastic, I had totally missed that.
I think the real issue is that VS Code is not picking up the env variables you are passing to the container. You should NOT have to create .env file. This will be an issue if you are passing, say keys or tokens, via env variables. You will have to change the file each time the key or token expires. The best way to test this is to disable Python extension in the container, connect to the container (with some env variable passed), then open a terminal, check if the env variable is available there.

If it is NOT there then we should file a bug on VS Code remote container extension.
If it is there but Python extension is not getting it for some reason then, it is for us to investigate further.

I started a new VSCode remote session and didn't load any extensions. Here's what I found. Many of the environmental variables are present. However, OI_VISION_DATA_ROOT is not. When I open a terminal in the container but outside VSCode and env | grep OI_VISION_DATA_ROOT I see it, but inside the container, I don't.
That particular variable is passed in the docker run command, as in docker run ... -e OI_VISION_DATA_ROOT=/store/vision_datasets \ .... Unfortunately, I don't know how all the other environmental variables are set, but I know that one is uniquely added there.

@karthiknadig I'm having the problem again and can't fix it this time. Based on what you said before I ran the run_adapter.py script from the terminal to see what the errors were. I got a bunch of ModuleNotFoundErrors, so I added print(sys.path) to the run_adapter.py file to see what was the problem. From the output, I could tell that the .env file is not being read, so I exported the environment variables from the terminal and they showed up next time I ran run_adapter.py. So now I can run /opt/conda/envs/tf2/bin/python /root/.vscode-server-insiders/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jsimonelli/orbital/base/core/projects/combo_dataset -s --cache-clear combo_dataset/tests with no problems yet still can't discover tests:
(base) [root@oicv3host projects]# /opt/conda/envs/tf2/bin/python /root/.vscode-server-insiders/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jsimonelli/orbital/base/core/projects/combo_dataset -s --cache-clear combo_dataset/tests
['/root/.vscode-server-insiders/extensions/ms-python.python-2020.5.80290/pythonFiles/testing_tools', '/root/.vscode-server-insiders/extensions/ms-python.python-2020.5.80290/pythonFiles', '/home/jsimonelli/orbital/base/core/oicv/src/py', '/home/jsimonelli/orbital/base/core/services/src/py', '/home/jsimonelli/orbital/base/core/projects', '/home/jsimonelli/orbital/base/core/OFL/src/py', '/home/jsimonelli/orbital/base/core/sandbox', '/home/jsimonelli/orbital/base/core/chameleon_client/src/py', '/opt/conda/envs/tf2/lib/python37.zip', '/opt/conda/envs/tf2/lib/python3.7', '/opt/conda/envs/tf2/lib/python3.7/lib-dynload', '/opt/conda/envs/tf2/lib/python3.7/site-packages']
[{"rootid": ".", "root": "/home/jsimonelli/orbital/base/core/projects/combo_dataset", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/unit", "kind": "folder", "name": "unit", "parentid": "./tests", "relpath": "./tests/unit"}, {"id": "./tests/unit/test_campaign_analyzer.py", "kind": "file", "name": "test_campaign_analyzer.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys", "kind": "function", "name": "test_create_all_keys", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict", "kind": "function", "name": "test_create_mapping_dict", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param", "kind": "function", "name": "test_find_matches_param", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test", "kind": "function", "name": "test_full_test", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2", "kind": "function", "name": "test_get_object_matches2", "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_extractor.py", "kind": "file", "name": "test_campaign_extractor.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_campaign_extractor.py"}, {"id": "./tests/unit/test_outlier_removal.py", "kind": "file", "name": "test_outlier_removal.py", "parentid": "./tests/unit", "relpath": "./tests/unit/test_outlier_removal.py"}, {"id": "./tests/unit/test_outlier_removal.py::test_full_test", "kind": "function", "name": "test_full_test", "parentid": "./tests/unit/test_outlier_removal.py"}], "tests": [{"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types0-2-ranking0-6-test_keys0-test_results0]", "name": "test_create_mapping_dict[obj_types0-2-ranking0-6-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types1-2-ranking1-6-test_keys1-test_results1]", "name": "test_create_mapping_dict[obj_types1-2-ranking1-6-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict[obj_types2-5-ranking2-3905-test_keys2-test_results2]", "name": "test_create_mapping_dict[obj_types2-5-ranking2-3905-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:11", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_mapping_dict"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs0-3-39-example_keys0]", "name": "test_create_all_keys[objs0-3-39-example_keys0]", "source": "./tests/unit/test_campaign_analyzer.py:34", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys[objs1-2-6-example_keys1]", "name": "test_create_all_keys[objs1-2-6-example_keys1]", "source": "./tests/unit/test_campaign_analyzer.py:34", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_create_all_keys"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "name": "test_find_matches_param[tests/unit/test_data/three_worker_missing.csv2-obj_types0-3-3-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:46", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_find_matches_param"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_find_matches", "name": "test_find_matches", "source": "./tests/unit/test_campaign_analyzer.py:64", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "name": "test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "source": "./tests/unit/test_campaign_analyzer.py:122", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_full_test"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "name": "test_get_object_matches2[tests/unit/test_data/complete_match.csv2-obj_types0-2-2-test_keys0-test_results0]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "name": "test_get_object_matches2[tests/unit/test_data/flipped_labels.csv2-obj_types1-2-2-test_keys1-test_results1]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "name": "test_get_object_matches2[tests/unit/test_data/no_matches.csv2-obj_types2-2-2-test_keys2-test_results2]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "name": "test_get_object_matches2[tests/unit/test_data/three_worker.csv2-obj_types3-3-2-test_keys3-test_results3]", "source": "./tests/unit/test_campaign_analyzer.py:146", "markers": [], "parentid": "./tests/unit/test_campaign_analyzer.py::test_get_object_matches2"}, {"id": "./tests/unit/test_campaign_extractor.py::test_nothing", "name": "test_nothing", "source": "./tests/unit/test_campaign_extractor.py:14", "markers": [], "parentid": "./tests/unit/test_campaign_extractor.py"}, {"id": "./tests/unit/test_outlier_removal.py::test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "name": "test_full_test[tests/unit/test_data/full_test.csv2-obj_types0-3]", "source": "./tests/unit/test_outlier_removal.py:7", "markers": [], "parentid": "./tests/unit/test_outlier_removal.py::test_full_test"}]}]
(base) [root@oicv3host projects]#

What should I try next?

@karthiknadig here's another example from a different system (directly on my laptop). I can run /Users/juliussimonelli/opt/anaconda3/envs/main/bin/python /Users/juliussimonelli/.vscode/extensions/ms-python.python-2020.5.86398/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/juliussimonelli/orbital/base/core/oicv -s --cache-clear tests with no problem - it shows all the test case results with no errors. But when I try to Discover Tests in VSCode I get an error that says "Test discovery error, please check the configuration settings for the tests. Source: Python (Extension)". I went through my Python extension settings and didn't see any errors.

@juliussimonelli  The issue is not that the command below fails. the issue is that it might have non json content in it (say if when loading a module it prints some stuff to stdout). Then the command will appear to run just fine, but test discovery will fail because we could not parse the content.
/Users/juliussimonelli/opt/anaconda3/envs/main/bin/python /Users/juliussimonelli/.vscode/extensions/ms-python.python-2020.5.86398/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/juliussimonelli/orbital/base/core/oicv -s --cache-clear tests

From your previous result... looks like something is printing out the contents of sys.path somewhere on module load. When you run the above command you should see something like this:
[{"rootid": ".", "root": ...

Looking at that previous result it looks like this:
['path','path',...]
[{"rootid": ".", "root": ...

This breaks parsing when we try to extract the test cases. See if something like this is occurring. One way to test this is copy the contents out to a file and name it something.json. VSCode should be able to find the place where json parsing is breaking. you could even try and do json.loads() in python to find the place where it breaks. IF everything is fine and it still breaks then another thing to check is the exit code.
We are planning on addressing this generically, so printing to stdout should not break discovery. #11729.

@karthiknadig Thanks for your reply. What you're saying makes sense and I'm glad to hear it's being fixed. Out of curiosity, I wanted to test it so I captured the output from:
/Users/juliussimonelli/opt/anaconda3/envs/main/bin/python /Users/juliussimonelli/.vscode/extensions/ms-python.python-2020.5.86398/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/juliussimonelli/orbital/base/core/oicv -s --cache-clear tests > 'test.json'
The beginning of the file looks like this:
[{"rootid": ".", "root": "/Users/juliussimonelli/orbital/base/core/oicv", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/
Perhaps the ['path','path',...] part was from a print command during debugging? But it looks like it is a json error like you suggested:

Although it suggests the first character is invalid and it looks like what you posted to me.

@juliussimonelli For loads you will need to pass the contents of test.json as string. try this:
import json

f = "test.json"
with open(f, "r") as fp:
    t = json.load(fp)

The solution to this issue is to use socket when running test discovery. This will be addressed by #6594

I kept poking around and managed to find an error message when I entered "pytest" into the command prompt

I went into the settings and wasn't sure what the error was but added the python.testing.cwd so that my settings were:
“python.testing.pytestEnabled”: true,
“python.testing.cwd”: “”

I tried to discover tests again and it failed and didn't give an error. But after restarting I tried again and got this error:

Then I tried both:
“python.testing.cwd”: “${workspaceFolder}/tests”
and
“python.testing.cwd”: “${workspaceFolder}”
but now I'm back to it failing and giving this error:

In my user settings I have:
    "python.testing.pytestEnabled": true,
    "python.testing.cwd": "${workspaceFolder}"

And in my project settings I have:
{
    "python.testing.pytestArgs": [
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": true
}

Not sure if this helps here, but I got the same python.discoverTests not found error. I had also reinstalled the Python extension but the language server hadn't downloaded, it was blocked by my company's proxy server. I reopened the project on a dirty connection, the language server downloaded and my tests were discovered.

authors: Poc275 juliussimonelli karthiknadig

repo: microsoft/vscode-python


text:
Resolve symlinks when running debugger in bazel sandbox

Discussed in https://github.com/microsoft/vscode-python/discussions/15897

Originally posted by koenlek April  8, 2021
I'm using bazel to build and run my python code. Bazel creates a 'runfiles' directory, which is used as a sandbox that contains all the runtime deps of my command. This runfiles directory is mainly made up by files that are symlinked into the directory.
When I run such code under the ptvsd debugger, it will open the file using the symlink path (i.e. the path in the runfiles directory), which is the same file as what I have in my git workspace. Luckily, it picks up my breakpoints as set on the original file properly, but it feels a bit messy, because:

I often end up with two open copies per file: the one from my git workspace, and the one from the runfiles directory (which luckily is a symlink)
Visually the UI doesn't sync both files well: break points set in either file will work, but will only show in one of both files...

Perhaps we could add a debug option: "dereference_symlinks"? If true, we make VSCode resolve the symlink to it's original path (readlink -f path/to/symlink)?
Note: my main use case is on Linux, but I think it should be straightforward to make this work on MacOS and Linux. For Windows I'm not so sure. I believe bazel has some experimental symlink runfiles support for Windows, so it might depend on that.

It looks like I've found a workaround for this. Just add the following to the debug config:
"pathMappings": [
    {"localRoot": "${workspaceFolder}", "remoteRoot": "${workspaceFolder}"}
],

Although this seems like a no-op, it actually seems to effectively take care of symlink resolution for us.

Thank you for submitting your feature request and everyone who considered it! Unfortunately this issue did not receive enough votes over the allotted time, and so we are closing the issue.

source: gharchive/issue

authors: brettcannon koenlek

license: MIT

license_type: permissive

license_source: github-api


text:
Add tests for pythonFiles/completion.py.

There are no tests for the pythonFiles/completion.py script (used for Jedi).  We need:

[ ] full unittest coverage
[ ] at least one full integration test
[ ] at least one system (functional) test

This will also require refactoring the script.

this file no longer exists

authors: ericsnowcurrently karthiknadig


text:
Cell created with add cell button doesn't get keyboard context

Select a cell in the native editor
Press the + icon in the gutter to get a new cell

Expected: New cell is created in edit mode and I can type
Actual: New cell is created and looks like edit mode, but the keyboard focus is lost somewhere, I can't type until I click in or esc - enter in and out.

Huh weird. Must be only when focus is already in another cell.

This works now. I tried pressing the button when the cell is either hovered, selected or focused and could always type on the added cell.

authors: DavidKutu IanMatthewHuff rchiodo


text:
Add node loader

For #14664

Codecov Report

Merging #14692 (d48495f) into main (cae62fd) will decrease coverage by 64.89%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             main   #14692       +/-   ##
===========================================
- Coverage   64.89%    0.00%   -64.90%
===========================================
  Files         547        4      -543
  Lines       25611        9    -25602
  Branches     3619        0     -3619
===========================================
- Hits        16619        0    -16619
+ Misses       8311        9     -8302
+ Partials      681        0      -681

Impacted Files
Coverage Δ

src/client/debugger/constants.ts
0.00% <0.00%> (-100.00%)
:arrow_down:

src/client/common/process/constants.ts
0.00% <0.00%> (-100.00%)
:arrow_down:

src/client/common/platform/constants.ts
0.00% <0.00%> (-100.00%)
:arrow_down:

src/client/interpreter/autoSelection/constants.ts
0.00% <0.00%> (-100.00%)
:arrow_down:

src/client/logging/levels.ts

...pplication/diagnostics/checks/pythonInterpreter.ts

src/client/testing/explorer/testTreeViewItem.ts

src/client/pythonEnvironments/info/interpreter.ts

...s/discovery/locators/services/interpreterFilter.ts

src/client/linters/linterManager.ts

... and 537 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cae62fd...767ff25. Read the comment docs.

source: gharchive/pull-request

authors: codecov-io karthiknadig


text:
Do underlying shadow elements support class names and inline styles?

Feature request
I want to justify my button content to the left, but the added class justify-left is put on the <vscode-button> element, which has no effect. I wonder how I can add the class to the underlying <button> element in the shadow root.
Expected behavior
Allow passing class names or inline styles to style the shadow elements.
Current behavior
Cannot style the button because the class names and inline styles are applied to the wrapper elements.
Use case
I'm trying to justify my button content to the left.
Screenshots/references
It would work if the class is passed to the actual <button> element instead:

+1 I'm trying to disable the default blue outline of a textarea but am unable to accomplish this

Hey @teddyfullstack! It's not well documented (apologies) but the part attribute/psuedo-element selector can be used to access/style elements within the shadow root.
You can read more about ::part() on MDN, but here's a basic example to give you an idea:
vscode-button::part(control) {
  background-color: red;
  /* insert other arbitrary styles */
}
vscode-button::part(control):hover {
  background-color: blue;
  /* insert other arbitrary styles */
}

Extra notes:

The part name "control" comes from FAST Foundation and is used widely across other components in the toolkit
There's no easy way to apply a class name to the elements in the shadow root thanks to how shadow DOM works and how FAST is built

Anyone who uses tailwindcss, can add a matchVariant plugin like this:
const plugin = require("tailwindcss/plugin");

/** @type {import('tailwindcss').Config} */
module.exports = {
  plugins: [
    plugin(function ({ matchVariant }) {
      matchVariant("part", (value) => {
        return `&::part(${value})`;
      });
    }),
  ],
};

and then use it:
<VSCodeButton
    className="part-[control]:justify-start part-[content]:flex-1"

authors: dinghar hawkticehurst teddyfullstack

repo: microsoft/vscode-webview-ui-toolkit

license: mit

license_source: bigquery


text:
Jupyter notebooks don't honor user or workspace indentation settings

Issue Type: Bug
I have both detect indentation and insert spaces disabled, and yet tab still inserts spaces in Jupyter notebooks.
VS Code version: Code 1.48.0 (db40434f562994116e5b21c24015a2e40b2504e6, 2020-08-13T07:50:42.600Z)
OS version: Windows_NT x64 10.0.19041

System Info

Item
Value

CPUs
Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)

GPU Status
2d_canvas: enabledflash_3d: enabledflash_stage3d: enabledflash_stage3d_baseline: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onoop_rasterization: disabled_offprotected_video_decode: enabledrasterization: enabledskia_renderer: disabled_off_okvideo_decode: enabledviz_display_compositor: enabled_onviz_hit_test_surface_layer: disabled_off_okwebgl: enabledwebgl2: enabled

Load (avg)
undefined

Memory (System)
15.75GB (7.19GB free)

Process Argv

Screen Reader
no

VM
0%

Extensions (7)

Extension
Author (truncated)
Version

vscode-markdownlint
Dav
0.36.2

kite
kit
0.122.0

python
ms-
2020.8.101144

remote-wsl
ms-
0.44.4

powershell
ms-
2020.6.0

synthwave-vscode
Rob
0.1.6

vscode-ansible
vsc
0.5.2

/extPython

authors: TKIPisalegacycipher rebornix

repo: microsoft/vscode


text:
Settings page keeps showing a (2) next to the user tab when using json mode

VSCode Version: 1.50.0-insider
OS Version: macOS Catalina 10.15.6

Steps to Reproduce:

Open setting page
Make sure to switch to json mode
Check the user tab

Does this issue occur when all extensions are disabled?: Yes

That is the number of search results

authors: pingshunhuangalex roblourens


text:
Asking for vscode github login

Issue Type: Bug
It is popping up every few seconds asking me for confidential information in vscode GitHub login. No steps are needed, I enter my password and it goes away only to pop up again in a few seconds.
VS Code version: Code 1.50.0

The same problem.

I am having the same issue. I thought my extensions were causing it, so I removed a lot of them because I didn't need most of them, and now I am left with C/C++, Pylance, and Python.

Yet, it keeps happening. I have even disabled all of the extensions above and it still pops up in several second intervals. So, this makes me think it has nothing to do with extensions

The issue was there in Insiders: https://github.com/microsoft/vscode/issues/107480
And then, they pushed the changes to stable channel without addressing it: https://github.com/microsoft/vscode/issues/108342
The issue has already been noted.

@all Please clarify whether you dismiss the dialog by clicking Allow or by clicking Always  Allow..

In my case it was just confusion, I initially thought the "Always allow" button was disabled as it was greyed out,

turns out it's not disabled. After clicking "Always Allow" it doesn't happen anymore.

@ALL Please clarify whether you dismiss the dialog by clicking Allow or by clicking Always Allow..

I am able to dismiss the prompt only with Always Allow, not with Allow.

Details from VS Code version: 1.50 release notes

related #108342

@ALL Please clarify whether you dismiss the dialog by clicking Allow or by clicking Always Allow..

When I press dismiss it go away then pops back up a few seconds later same with allow, when I press always allow, it stay gone a little longer but it will pop back up.

Same issue for deny.

It happens to me too but I cannot click anything other than Deny because it does not accept my valid GitHub password. Pops up again every 15 seconds after dismissing.

It happens to me too but I cannot click anything other than Deny because it does not accept my valid GitHub password. Pops up again every 15 seconds after dismissing.

You have to enter the password for your user account, not the GitHub password.

It happens to me too but I cannot click anything other than Deny because it does not accept my valid GitHub password. Pops up again every 15 seconds after dismissing.

You have to enter the password for your macOS user account, not the GitHub password.

Thanks for your response @cyberpirate92, I clicked Always Allow after entering my macOS account password and it has not popped up ever since. 👌🏼

Merging to https://github.com/microsoft/vscode/issues/108342#issuecomment-706340396 , please check that comment for background.

authors: LuvTian SachinShekhar WesleySalesberry cyberpirate92 deepak1556 devmachiine ghostraddish gjsjohnmurray jogo- sampittko


text:
Integration tests: lots of ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawArrays: framebuffer incomplete

When running integration tests (on macOS) I see tons of this output:
ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawArrays: framebuffer incomplete
Disabling minimap in settings helps, so I will push that as a workaround.

I have spent quite some time trying to understand this. I could reproduce by just replacing the entire minimap rendering code with the following:
const ctx = this._canvas.domNode.getContext('2d')!;
const tmpImageData = ctx.createImageData(this._canvas.domNode.width, this._canvas.domNode.height);
ctx.putImageData(tmpImageData, 0, 0);

I have added checks that the canvas element is in the dom when using putImageData and AFAICT I am doing everything OK. So it looks to me that this is an issue with Chromium itself that surfaces in the rapid case of creating the canvas, using createImageData, using putImageData and then removing the canvas from the DOM. We can continue with the workaround to disable minimap in integration tests.

Thanks for the minimal repro, I was able to verify the error is seen with electron nightly. Test used
for (let i = 0; i < 100; i++) {
  let canvas = document.createElement('canvas')
  document.body.appendChild(canvas)
  let ctx = canvas.getContext('2d')
  let tmpImageData = ctx.createImageData(200, 400);
  ctx.putImageData(tmpImageData, 0, 0);
  document.body.removeChild(canvas)
}

Similar issue https://bugs.chromium.org/p/chromium/issues/detail?id=1124738 , unless the error causes a visual regression or impacts the runtime, this won't get much attention in upstream.

authors: alexdima bpasero deepak1556


text:
TS Server fatal error:  Cannot read property 'lastIndexOf' of undefined

Issue Type: Bug
❗❗❗ Please fill in the sections below to help us diagnose the issue ❗❗❗
TypeScript Version: 4.2.2
Steps to reproduce crash
1.
2.
3.
TS Server Log
❗Server logging disabled. To help us fix crashes like this, please enable logging by setting:
"typescript.tsserver.log": "verbose"

After enabling this setting, future crash reports will include the server log.
TS Server Error Stack
Server: semantic
TypeError: Cannot read property 'lastIndexOf' of undefined
    at Object.startsWith (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:2024:20)
    at isNodeModulesOrScopedPackageDirectory (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:19068:65)
    at guessDirectorySymlink (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:19056:17)
    at Object.discoverProbableSymlinks (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:19044:22)
    at ConfiguredProject.Project.getSymlinkCache (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:153426:61)
    at Object.getSymlinkCache (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:108820:29)
    at Object.host.compilerHost.realpath (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:108879:36)
    at realPath (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:39626:42)
    at Object.resolveTypeReferenceDirective (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:39075:74)
    at c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154782:112
    at Object.map (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:451:29)
    at Function.AutoImportProviderProject.getRootFileNames (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154782:42)
    at Function.AutoImportProviderProject.create (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154811:38)
    at ConfiguredProject.Project.getPackageJsonAutoImportProvider (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154625:77)
    at ConfiguredProject.Project.updateGraph (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154023:26)
    at ConfiguredProject.updateGraph (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:154958:63)
    at ProjectService.createLoadAndUpdateConfiguredProject (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:156708:25)
    at ProjectService.assignProjectToOpenedScriptInfo (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:157649:44)
    at c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:157989:97
    at Object.flatMap (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:515:25)
    at ProjectService.applyChangesInOpenFiles (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:157989:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:159044:46)
    at c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:160928:88
    at IOSession.Session.executeWithRequestId (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:160919:28)
    at IOSession.Session.executeCommand (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:160928:33)
    at IOSession.Session.onMessage (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:160954:35)
    at Interface.<anonymous> (c:\Users\skydo\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:163615:31)
    at Interface.emit (events.js:315:20)
    at Interface._onLine (readline.js:329:10)
    at Interface._normalWrite (readline.js:474:12)
    at Socket.ondata (readline.js:186:10)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)

VS Code version: Code 1.54.1 (f30a9b73e8ffc278e71575118b6bf568f04587c8, 2021-03-04T22:38:31.419Z)
OS version: Windows_NT x64 10.0.19041

System Info

Item
Value

CPUs
Intel(R) Core(TM) i5-1035G7 CPU @ 1.20GHz (8 x 1498)

GPU Status
2d_canvas: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onoop_rasterization: enabledopengl: enabled_onprotected_video_decode: enabledrasterization: enabledskia_renderer: enabled_onvideo_decode: enabledvulkan: disabled_offwebgl: enabledwebgl2: enabled

Load (avg)
undefined

Memory (System)
7.60GB (0.98GB free)

Process Argv
--crash-reporter-id f0c82c41-7867-4d0e-8f29-0976c0ec1a1f

Screen Reader
no

VM
0%

Extensions (14)

Extension
Author (truncated)
Version

Bookmarks
ale
13.0.3

aws-toolkit-vscode
ama
1.20.0

aws-cloudformation-yaml
Dan
0.2.2

gitlens
eam
11.3.0

vsc-material-theme
Equ
33.1.2

vsc-material-theme-icons
equ
1.2.2

prettier-vscode
esb
5.9.2

php-intellisense
fel
2.3.14

go
gol
0.23.0

vscode-graphql
Gra
0.3.15

prettify-json
moh
0.0.3

aws-step-functions-constructor
pau
0.8.1

material-icon-theme
PKi
4.5.0

velocity
sod
0.2.0

(1 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
pythonvspyt617cf:30253240
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vstry244:30256636
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
dockersubsetcf:30265999
pythontbcf:30265426
vspre833:30267464

/duplicate of #118335


text:
I have no access to my Automator Services from contextual menus

Issue Type: Feature Request
I'm just trying out Visual Studio code for the first time and I wanted to run one of my custom services I wrote on some selected text.  I right-clicked the selected text and there was no services sub-menu provided by the system.  It's going to get old real quick to copy text out into a different editor to be able to run services in it.
VS Code version: Code 1.54.1 (Universal) (f30a9b73e8ffc278e71575118b6bf568f04587c8, 2021-03-04T22:42:18.719Z)
OS version: Darwin x64 19.6.0

Is there a way to access the system contextual menu from right-clicks of selected text?  Like, is there a modifier key to hold down which right-clicking?

I assume you're referring to this item in the macOS native context menu? cc @deepak1556 for if electron can do this.

Yes, exactly.  I'm a computational biologist and I have lots of string processing code, such as blasting sequences that might be included in a file I'm working on, or reverse complementing, or... well, let me just paste a screenshot of my services:

I use these every day.

Runtime does not support this feature, closing as not planned.


text:
Improve toolbar UX

Here's a couple of variations from @misolori:
Toolbar hovers

Run split button

duplicates https://github.com/microsoft/vscode/issues/117722?

@jrieken I would keep things separate and just have this affect the UX of existing actions.

I can't see hover feedback on collapse arrow in folder left sidebar :(

@kytosai the tree view chevrons were not included in this original change as this was scoped to toolbar actions. Will try to get this in the next iteration.

authors: joaomoreno jrieken kytosai misolori


text:
Unable to copy from HTML output of a Notebook

Version: 1.56.0-insider
Commit: 01466cf692c3e54f0eeb82ef0539a42391f185de
Date: 2021-04-12T05:14:36.459Z
OS: Darwin x64 20.3.0

Steps to Reproduce:

Install Jupyter Extension
Run  the following cell

%%html

Hello World

Try to copy the output Hello World, and it doesn't work.

I'm certain I've seen a duplicate, but couldn't find this.
Also I believe this is a regression.
@rebornix /cc

Does this issue occur when all extensions are disabled?: N/A

I believe this is a regression.

authors: DonJayamanne rebornix


text:
Insiders DEB package 1.56.0-1618572971 amd64 missing dependency libxshmfence1

VS Code Version: code-insiders/stable 1.56.0-1618809920
OS Version:  Debian 10: Linux 5.10.0-0.bpo.4-amd64 #1 SMP Debian 5.10.19-1~bpo10+1 (2021-03-13) x86_64 GNU/Linux

The package seems to have been published on the feed within the last 8 hours.
Steps to Reproduce:

Upgrade the code-insiders package from 1.56.0-1618572971 to 1.56.0-1618809920 via apt upgrade
Start code-insiders. A missing SO library is immediately reported:

$ code-insiders
/usr/share/code-insiders/bin/../code-insiders: error while loading shared libraries: libxshmfence.so.1: cannot open shared object file: No such file or directory

Workaround/fix:
Install the libxshmfence1 package. After that, code-insiders is nominal.
APT feed the package came from, to be entirely precise:
$ cat /etc/apt/sources.list.d/vscode.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main

Code pointer:
https://github.com/microsoft/vscode/blob/b47d277a2e109252558160f0874b8a0804d73c9e/resources/linux/debian/control.template#L4
https://github.com/microsoft/vscode/blob/main/resources/linux/rpm/dependencies.json

after install vscode on our debian servers, found that these packages were missing in Depends, so I need to install them manualy.
missing packages in Depends:
libasound2
libunwind8
libdrm
libxshmfence1
and for working X11 forwarding:
and for working Xserver redirect
libx11-xcb1

authors: Tyriar kkm000 puresoul


text:
[Getting Started] selectTask telemetry event stopped working

Probably a regression from #120050.

Ah, so we renamed everything from task to step as task is overloaded in vscode to typically refer to tasks.json tasks: https://github.com/microsoft/vscode/issues/120049
I'll go ahead and change the telemetry event back to task so we don't have to deal with two potential names.

authors: JacksonKearl digitarald


text:
Unable to configure edito associations in settings.json workbench.editorAssociations used to be an array

VS Code Version: Insiders 1.57
OS Version: Mac

Steps to Reproduce:

Open settings.json
Try to configure workbench.editorAssociations
This used to be an array, now it seems to be some object without any structure (no completions)

@rebornix /cc

Does this issue occur when all extensions are disabled?: Yes/No

Added z-author-verified based on above comment


text:
Suspend background windows to save memory

Is it possible to implement an option to be able to suspend background windows (that haven' t been used for 2 days) to save memory. Something like the Edge browser can do . Would be useful for people with a lot of system workspaces and windows open that might be used once a week, and put to some background system workspace most times.

This is best achieved in the runtime and not at the application level. Also, we already get this resource management for free from the various optimizations chromium and v8 does for background tabs, for ex:
https://blog.chromium.org/2021/03/advanced-memory-management-and-more.html
https://blog.chromium.org/2020/11/tab-throttling-and-more-performance.html
We have disabled the occlusion tracker on windows due to https://github.com/microsoft/vscode/issues/123257 but we are working to enable it back. There are places in the application code that can be adjusted to better work with visibility apis to conserve resources, any PR to fix that is welcome. But explicit option to suspend specific windows cannot be done without support from the runtime.


text:
:e! to be remapped (workbench.action.files.openFile failed)

https://github.com/microsoft/vscode/issues/5437
touches on this but I can't comment since it's closed.
using :e! to discard changes to the current buffer (reverting the file) doesn't work, but gives an error with:
workbench.action.files.openFile failed, args: [] error: command 'workbench.action.files.openFile' not found

However, the fix is rather simple:
if exists('g:vscode')
    " e! should reload the file in vscode
    command! -bang -nargs=? Edit call VSCodeNotify('workbench.action.files.revert'>
endif

It seems reasonable this should be the default. Is there any reason it's not?

I have no idea what you are talking about :-/. What is that script?

oops, this was meant for the neovim vscode plugin

Ah that is what I thought, thanks for clarifying!


text:
Native Notebooks - Multiple change output mimetype buttons

VSC Version: 1.58.0-insider

this means jupyter emits multiple outputs, each of which are multi-mimetype outputs.

authors: claudiaregio rebornix


text:
When opening up a JSON file VSCode crashes with "Error: Cannot find module"

Does this issue occur when all extensions are disabled?: Yes

VS Code Version: 1.58.2
OS Version: Windows 10 21H1 (19043.1149)

Steps to Reproduce:

Try to open a JSON file
VSCode crashes with below error:

Does this reproduce with all extensions disabled?

authors: aeschli gabloe


text:
Remote SSH - Git: gpg failed to sign the data

Does this issue occur when all extensions are disabled?: Yes/No

VS Code Version: 1.59.0

OS Version:
Version: 1.59.0 (user setup)
Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8
Date: 2021-08-04T23:13:12.822Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Windows_NT x64 10.0.19043

Steps to Reproduce:
I'm using Remote - SSH from Windows 10 to Ubuntu 20.04 LTS.

Add the following code to ~/.profile
export GPG_TTY=$(tty)

Configure git
git config --global commit.gpgsign true
git config --global --unset gpg.program
git config --global --add gpg.program /usr/bin/gpg

Enable Commit Signing

Commit

Open Git Log
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - -S
error: gpg failed to sign the data
fatal: failed to write commit object
> git config --get-all user.name
> git config --get-all user.email

Show Command Output
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - -S
error: gpg failed to sign the data
fatal: failed to write commit object

I seems related with this issue: https://github.com/microsoft/vscode-remote-release/issues/1022

As a workaround:

Open Terminal and commit once
export GPG_TTY=$(tty)
git commit -m "OK" -S

...Enter your password...

Git Reset
git reset HEAD~

Then you can use VSCode git commit signing

I put export GPG_TTY=$(tty) into my ~/.profile, but opening Terminal in VSCode when using Remote SSH will not apply. So the git commit -S will fail. I have to run this export GPG_TTY=$(tty) manually after open Terminal.  I don't know how to workaround that.

I can confirm the problem. I am using remote SSH from a Windows machine developing on a Linux machine.  I have export GPG_TTY=$(tty) in my .profile. But I have to manually export it in the console and sign something once in the console (e.g. echo "test" | gpg2 --clearsign) to be able to use VSCode to use signed git commits.

I can confirm the problem. I am using remote SSH from a Windows machine developing on a Linux machine. I have export GPG_TTY=$(tty) in my .profile. But I have to manually export it in the console and sign something once in the console (e.g. echo "test" | gpg2 --clearsign) to be able to use VSCode to use signed git commits.

Yup, can confirm the same behaviour in same environment (win10 -> Centos7).

Is there any update on this issue?

Still no native solution. @swills1 answer is still valid.
What you can do is to overwrite the default timeout for the gpg cache. Open/Create ~/.gnupg/gpg-agent.conf and add the following lines:
max-cache-ttl 32400
default-cache-ttl 32400

This keeps you gpg key cached for 9 hours (32400 sec), starting from the first unlock (-> default-cache-ttl). After 9 hours, you need to unlock again, because that is the maximum time (max-cache-ttl).
It is a work-around to not be bothered during a work-day.

same problem:
Version: 1.68.1 (Universal)
Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630
Date: 2022-06-14T12:52:13.188Z
Electron: 17.4.7
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Darwin arm64 22.0.0

Remote-SSH: v0.82.1

Any breakthrough here, its not working for windows 10 -> rhel

Fedora users put export GPG_TTY=$(tty) in ~/.bash_profile and run source ~/.bash_profile.

Not working on Debian for me. I just did what someone said earlier, but I need to do this every single time I re-connect/open up VSCode, so it's not really a solution: echo "test" | gpg --sign and after entering my pass, I can commit in VS Code.
What's interessting: my .bashrc does get executed on login, as I have many things in there alongside powerline, and powerline is usable/enabled from within vscode, so the "GPG_TTY" thing must not be the issue on debian I suppose?
Any update?

To avoid retyping export GPG_TTY=$(tty) manually you can tell VSCode to start bash like a login shell by passing the -l parameter to the bash command. You can do that by adding "args": ["-l"] in the terminal.integrated.profiles.linux setting of VSCode:
"terminal.integrated.profiles.linux": {
    "bash": {
        "path": "bash",
        "args": ["-l"],
        "icon": "terminal-bash"
    }
},
"terminal.integrated.defaultProfile.linux": "bash"

Make sure echo "test" | gpg --clearsign runs successfully first before trying the below.
Very helpful to check what git commit is doing under the hood. Run the following commit with GIT_TRACE=1 as follow
GIT_TRACE=1 git commit -S -m "MESSAGE"
This will show what user name, email, and key git uses when committing.
In my case, I found that git was picking up the wrong user and key details for signing the commit. I mainly intended to use the local config of the repo rather than the global and adding the following to the local git config (located at "REPO_PATH/.git/config") got signing the commit to work both in Terminal and VSCode.
[user]
    name = USER NAME
    email = USER EMAIL
    signingKey = SIGNING KEY

It can also be set with the following:
git config --local user.name "USER NAME"
git config --local user.email "USER EMAIL"
git config --local user.signingkey "USIGNING KEY"

I can confirm the problem. I am using remote SSH from a Windows machine developing on a Linux machine. I have export GPG_TTY=$(tty) in my .profile. But I have to manually export it in the console and sign something once in the console (e.g. echo "test" | gpg2 --clearsign) to be able to use VSCode to use signed git commits.

I remote ssh into a linux VM. In the VM, I can commit with gpg, but Vscode does not work (same error).
After executing echo "test" | gpg2 --clearsign and type my password, I could commit in Vscode with no issue.
Thanks.

I can confirm the problem. I am using remote SSH from a Windows machine developing on a Linux machine. I have export GPG_TTY=$(tty) in my .profile. But I have to manually export it in the console and sign something once in the console (e.g. echo "test" | gpg2 --clearsign) to be able to use VSCode to use signed git commits.

I remote ssh into a linux VM. In the VM, I can commit with gpg, but Vscode does not work (same error). After executing echo "test" | gpg2 --clearsign and type my password, I could commit in Vscode with no issue. Thanks.

What OS?

For all the people who're struggling with signing commits via remote VS Code sessions even after setting the GPG_TTY environment variable and the gpg program for git.

Try to expand the terminal window or move it to a tab. Increasing the terminal window size may help.

If you try to run something like "test" | gpg2 --clearsign as others in this thread stated, gpg may inform you about the insufficient screen/window size: gpg: signing failed: Screen or window too small.

If you expand it, that may work.

Restarting VSCode worked for me when I confirmed it was working on my terminal (after adding export GPG_TTY=$(tty) to my .zshrc)

I've tried all the workarounds mentioned in this thread and still can't commit via VScode.   In my case the remote host is an AWS linux ec2 instance.

I'm not sure this is even related to remote coding.
I am running VSCode on my Arch Linux machine, not remote connection at all, and still facing this same issue. Signing something once through the terminal once before trying to use the VSCode UI works, but that seems like a hack more than anything. Would be happy to see this properly fixed one day.

This is in response to all of the recent replies. I genuinely don't feel like this is a bug. I feel like it is not knowing where to save your settings on your specific OS. If you use my reply before this as an example - my issue was simply that I wasn't saving the env variable in the right profile. Once I did that it has been fixed every since. I don't feel like this is a bug, and that this is being beaten to death.
I feel like a good way to solve would be to - look up where your OS saves env variables / profile info. Then set an env variable and test pulling that variable. If it comes back - you know you have the right place. Stick your signed commit line in there and you should be good to go.

after a reboot(this is important) the environment variable has been picked up by vscode and I no longer encounter this issue

You could also kill your VS Code Server and connect again without restarting the machine. To do this, open a command palette using Shift + Ctrl + P and type kill. There are a couple of options to choose from.

I don't know if it was a fluke or something with Fedora 36. But I had put export GPG_TTY=$(tty) in ~/.bash_profile and run source ~/.bash_profile. And I was good for the longest time. Then suddenly I had to start doing this again;
export GPG_TTY=$(tty)
Run echo "test" | gpg2 --clearsign

After and upgrade to Fedora 37, things are working again with having to do those two steps. Just an FYI in case anyone on F36 saw something weird.
Key take away: Fedora 37 - adding GPG_TTY=$(tty)in~/.bash_profile` and running source ~/.bash_profile allows you to sign commits without doing any manual steps.

> export GPG_TTY=$(tty)
> echo test | gpg --clearsign --debug-level advanced
gpg: enabled debug flags: memstat trust extprog
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

test
gpg: signing failed: Timeout
gpg: [stdin]: clear-sign failed: Timeout
gpg: keydb: handles=2 locks=0 parse=2 get=2
gpg:        build=0 update=0 insert=0 delete=0
gpg:        reset=0 found=2 not=0 cache=0 not=0
gpg: kid_not_found_cache: count=0 peak=0 flushes=0
gpg: sig_cache: total=4 cached=4 good=4 bad=0
gpg: random usage: poolsize=600 mixed=1 polls=0/4 added=24/960
              outmix=0 getlvl1=0/0 getlvl2=0/0
gpg: rndjent stat: collector=0x0000000000000000 calls=0 bytes=0
gpg: secmem usage: 1344/65536 bytes in 2 blocks

Still won't work...

on ubuntu:
sudo apt install pinentry-gtk2
echo "pinentry-program /usr/bin/pinentry-x11" >> ~/.gnupg/gpg-agent.conf  #pinentry-gtk2 is ok too
gpg-connect-agent reloadagent /bye

and it began asking for a passphrase in the graphic interface.
Tested on WSL, may require Remote X11(SSH) extension and X11 Forwarding enabled on remote server when using SSH.

really need pinentry input support on VSCode, even if pinentry-tty.

For those on macOS, trying to commit will give a Git: gpg failed to sign the data error.

The only way to commit without this error is if you do a commit from the command line:
$ git commit -m "Changed description"
$ git push

This error happens because Visual Studio Code does not ask for the passphrase.

I can confirm that @FrostleafChan 's workaround (https://github.com/microsoft/vscode/issues/130415#issuecomment-2093371365) works for me on Win11+WSL+Ubuntu. Thank you!

Are no contributors/maintainers going to comment on this? It'd be great to get additional insight on the issue, or even some challenges that aren't obviously apparent on fixing this issue. I'm not exactly sure on a fix but running echo "test" | gpg2 --clearsign before every vscode remote session fixes the issue, which leads me to believe it's a vscode issue?

Same problem on Win10 with WSL2 and SUSE Tumbleweed.
All solutions above are hiding it by storing password in TTL ... not actually solving problem.

I know I'm late and I hate to add more to this, but I know on Linux if you add an option to your bashrc, you don't have to run the command every time. There is a comment above where I wrote the instructions for Fedora. It's been working for me ever since.

I know I'm late and I hate to add more to this, but I know on Linux if you add an option to your bashrc, you don't have to run the command every time. There is a comment above where I wrote the instructions for Fedora. It's been working for me ever since.

Signing commits works fine from terminal, but they do not work in VSCode GUI when working with a remote SSH system unless you first trigger the pinentry manually via terminal. Your comments seem like you don't understand that this issue is specifically about triggering the GPG pinentry without using terminal first.
I can sign commits just fine if I just SSH to my remote system from a terminal, they work fine if I use the terminal in VSCode to trigger the pinentry, they work fine on the local system, but if I don't first trigger pinentry from the terminal in VSCode, no pinentry dialog appears and VSCode just reports an error.

As a (temporary) workaround, one could also use this extension called GPG Indicator which allows you to manually unlock the key before committing via VS Code (UI alternative to the clear sign command).

As a (temporary) workaround, one could also use this extension called GPG Indicator which allows you to manually unlock the key before committing via VS Code (UI alternative to the clear sign command).

I just stumbled upon that same extension myself a moment ago. Kind of a clunky workaround, but better than nothing or jumping to the terminal just for the pinentry.

@swills1 It's pointless to keep repeating yourself when I already said that doesn't work.

@swills1 It's pointless to keep repeating yourself when I already said that doesn't work.

I didn't repeat myself. I expanded my point to make it more clear. It's working fine for me and has been since 2022. If you post your bashrc (assuming you're using an OS that utilizes one), I'd be more than happy to check it for issues.
I understand you're frustrated at your siatuation and your situation matters more to you because it im[acts you directly, but take a beat before replying. We're all here just trying to offer what works for different use cases. Take care.

authors: AndreHorst FrostleafChan Nicryc SpeedyCraftah WereCatf ahmedsalhin aljaxus crt0r d0x7 damian123 davideluque doggy8088 its-DomeE jaskirat8 jason-curtis lgrachov linroex liqimore marcelmamula markhc scott-laj-pfe scruel sirlupusdev swills1


text:
Expose TestItemCollection @@iterator publicly

The TestItemCollectionImpl has an @@iterator. It would be nice to be able to use this and be able to break out of a loop early instead of only being able to use .forEach.

While I definitely agree with you that this would be nice to have, this is an intentional decision. We don't expose ES6 constructs in our API yet.


text:
Webview-related 404 in smoke test output

I'm seeing the following logged when running smoke tests in CI:
Playwright ERROR: HTTP status 404 for https://f54da407-2248-490a-8369-3a794df1f37d.vscode-webview.net/insider/619f88ad7d4aed5cbe0b55e4d2ff89ffed6c71c3/out/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=b0615b4d-b2e0-450e-af17-a6fdbcf698c4

https://dev.azure.com/monacotools/Monaco/_build/results?buildId=143259&view=logs&j=672276a2-8d3a-5fab-615d-090c51352f92&t=d239d20c-b192-5a3e-69bb-696f63b250a5&l=80

Duplicate of #130027. Not actual  webview related, we're just re-using the vscode-webview endpoint here

authors: Tyriar mjbvz


text:
const { xor } = require("cypress/types/lodash"); added to top of file randomly

Issue Type: Bug
Extension Name: typescript-language-features
Extension Version: 1.0.0
OS Version: Darwin x64 19.6.0
VS Code version: 1.62.3

{
	"messages": [],
	"activationTimes": {
		"codeLoadingTime": 42,
		"activateCallTime": 48,
		"activateResolvedTime": 109,
		"activationReason": {
			"startup": false,
			"extensionId": {
				"value": "vscode.typescript-language-features",
				"_lower": "vscode.typescript-language-features"
			},
			"activationEvent": "onLanguage:javascript"
		}
	},
	"runtimeErrors": [],
	"runningLocation": 1
}

Hi there. Once about every 100 file saves, VSCode will write
const { xor } = require("cypress/types/lodash");
To the top of a JS file when I save it.
Here are my running extensions. This was happening before I installed Prettier.

Does this reproduce in the latest VS Code insiders build with all extensions disabled?

authors: ab-gord mjbvz


text:
Why native formatter doesn't work?

something must be going wrong i think, the formatter was good last week until today i was clicking the right-mouse button and select format incase to format the .vue document, but i got nothing response.  i thought was my fault to setup the wrong step first, but then when my colleague told me the same problem was show up, and he didn't change any thing

/needsMoreInfo including version, platform, and whether the Start Extension Bisect command points to any of your extensions being the cause of the issue.

authors: CookieJack gjsjohnmurray


text:
Newline missing when pressing Enter between open/close html tags in React files when tags have attributes

Issue Type: Bug
I found this same issue in https://github.com/microsoft/vscode/issues/65955 but it's been closed/resolved.
I'm still having the same issue where the close tag and cursor move to the next line with the correct indentation but it works fine without any attributes.
Steps to Reproduce

Open a tsx file

Write any JSX open and close tag without attributes in one line

Press Enter and it results in something like this

Now write the JSX with an attribute and Press Enter and I get this

VS Code version: Code - Insiders 1.66.0-insider (6dca4c1a1f7bb3529074601eb32938526fa9ecc7, 2022-03-04T05:18:46.542Z)
OS version: Darwin x64 21.3.0
Restricted Mode: No

System Info

Item
Value

CPUs
Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz (4 x 1400)

GPU Status
2d_canvas: enabledgpu_compositing: enabledmetal: disabled_offmultiple_raster_threads: enabled_onoop_rasterization: enabledopengl: enabled_onrasterization: enabledskia_renderer: disabled_off_okvideo_decode: enabledwebgl: enabledwebgl2: enabled

Load (avg)
2, 3, 5

Memory (System)
4.00GB (0.03GB free)

Process Argv
--crash-reporter-id 521e3195-bf0c-4b2b-913a-cfa46066d6bb

Screen Reader
yes

VM
0%

Extensions (42)

Extension
Author (truncated)
Version

better-comments
aar
2.1.0

github-markdown-preview
bie
0.2.0

markdown-checkbox
bie
0.3.2

markdown-emoji
bie
0.2.1

markdown-footnotes
bie
0.0.7

markdown-preview-github-styles
bie
1.0.1

markdown-yaml-preamble
bie
0.1.0

vscode-tailwindcss
bra
0.7.7

npm-intellisense
chr
1.4.1

path-intellisense
chr
2.8.0

postcss
css
1.0.9

vscode-markdownlint
Dav
0.46.0

vscode-eslint
dba
2.2.2

githistory
don
0.6.19

typescript-notebook
don
2.0.6

gitlens
eam
12.0.1

vscode-npm-script
eg2
0.3.24

el-vsc-product-icon-theme
ElA
0.1.8

prettier-vscode
esb
9.3.0

git-project-manager
fel
1.8.2

vscode-pull-request-github
Git
0.36.2

gitkraken-authentication
git
1.0.3

vscode-env
Iro
0.1.0

svg
joc
1.4.17

vscode-codemetrics
kis
1.24.0

mongodb-vscode
mon
0.8.0

vscode-autoprefixer
mrm
3.0.1

vscode-docker
ms-
1.20.0

live-server
ms-
0.2.12

vscode-typescript-next
ms-
4.7.20220305

color-highlight
nau
2.5.0

vscode-versionlens
pfl
1.0.9

material-icon-theme
PKi
4.13.0

material-product-icons
PKi
1.1.2

vscode-thunder-client
ran
1.12.2

vscode-yaml
red
1.4.0

bash-beautify
sha
0.1.1

vscode-fileutils
sle
3.5.0

code-spell-checker
str
2.1.7

errorlens
use
3.4.1

vscodeintellicode
Vis
1.2.17

vscode-wakatime
Wak
18.0.6

A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30422396
pythontb:30258533
pythonvspyt551:30291412
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
pythonvspyt200:30323110
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30404738
wslgetstartedc:30421358
vsclayoutctrc:30405799
dsvsc009:30440021
pythonvsnew555:30438690
vsbas813:30436447
vscscmwlcmt:30428973
azactmsalcf:30432849
vscgsvidc:30433759
cppdebug:30437091
dockersurvey3:30438168
pynewfile477cf:30443520

Preview ⬇
https://user-images.githubusercontent.com/55806855/156924862-6c901fc2-5ab8-49d5-a418-c3dd95472a5e.mov

Reopening to track fixing in recovery build

Closing, as this has been fixed in the release branch.

authors: hediet iammola mjbvz


text:
Find all usages of a props in React

I want to find all usage of a props of a component in React. For example, I have a <CustomComponent> that takes a lot of optional props, and want to know where is the (optional) props is used/passed.

Please share an example  project with steps to follow that demonstrates the issue

Hi, this is a feature request. For example, I have this component:
const Component = (props) => {
  const {optionalA, optionalB} = props;

  if (optionalA !== undefined) // do something

  return ...
}

Now if I use Find References on optionalA, I want it to also show these:
<Component optionalA>

but not these:
<Component /* optionalA not used */ >

This is already supported if you add JSDoc type annotations to props (notice how the inferred type is any without them, meaning we don't understand the shape of the types being used):
/**
 * @param {{
 *  optionalA: string | undefined,
 *  optionalB: string | undefined
 * }} props
 */
const Component = (props) => {
    const { optionalA, optionalB } = props;
...
}

authors: mjbvz nvmnghia