Skip to content

TypeError: this.context.getEnvironmentVariableCollection is not a function #21831

Description

Type: Bug

I'm running code version 1.81.1 and python 3.11.3 using Arch linux. I've tried the pre-release and release version of the python extension with identical results. The python extension won't load properly, the log shows an error as soon as I open any python workspace:

2023-08-17 10:19:17.604 [error] [ 'Failed to activate a workspace, Class name = g, completed in 256ms, has a falsy return value, Arg 1: , Return Value: undefined', [TypeError: this.context.getEnvironmentVariableCollection is not a function at _.activate (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:440573) at /home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2386 at Array.map () at g.activateWorkspace (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2376)] ]

A lot of stuff won't work (including the "Python: Report Issue..." command, but also basic stuff like auto completion, Ctrl+Click to jump to definitions, ...). I'm not sure if the cause of this is actually the error above, but I couldn't find anything else that looked suspicious. There were no issues before I recently updated from version 1.79.2 to 1.81.x.

I did not find any other reports that look similiar to this, so I'd guess it's an issue somewhere on my side. However, I was unable to find a solution, so I still ended up filing an issue to receive some support.

Extension version: 2023.15.12221007
VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-11T08:12:48.924Z)
OS version: Linux x64 6.4.10-arch1-1
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz (6 x 3900)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 0, 1, 1
Memory (System) 31.10GB (22.67GB free)
Process Argv
Screen Reader no
VM 0%
DESKTOP_SESSION undefined
XDG_CURRENT_DESKTOP undefined
XDG_SESSION_DESKTOP undefined
XDG_SESSION_TYPE tty
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vshan820:30294714
vstes263cf:30335440
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
3biah626:30602489
89544117:30613380
showlangstatbar:30737416
03d35959:30757346
pythoncmv:30756943
fixshowwlkth:30771522
showindicator:30805244
i26e3531:30792625
asynctok:30810527
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30812749

Activity

  1. karrtikr commented on Aug 17, 2023

    @karrtikr

    Two things:

    • Can you please provide the output?

      Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

      XXX
      

    • Try setting "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"] in User settings and reload window.

  2. karrtikr commented on Aug 17, 2023

    @karrtikr

    The issue should also go away if you update your Python extension to latest stable release.

  3. Patschke commented on Aug 18, 2023

    @Patschke
    Author

    Sure, here is the additional information:

    Full output for `Python` in the `Output` panel after starting code and opening a Python project:
    2023-08-18 08:11:44.024 [info] Experiment 'pythonaacf' is active
    2023-08-18 08:11:44.024 [info] Experiment 'pythonDiscoveryModuleWithoutWatcher' is active
    2023-08-18 08:11:44.024 [info] Experiment 'pythonTensorboardExperiment' is active
    2023-08-18 08:11:44.025 [info] Test server listening.
    2023-08-18 08:11:44.026 [info] Python interpreter path: /bin/python
    2023-08-18 08:11:44.296 [error] [
      'Failed to activate a workspace, Class name = g, completed in 276ms, has a falsy return value, Arg 1: <Uri:/home/user/git/path/to/the/currently/open/pythonfile.py>, Return Value: undefined',
      [TypeError: this.context.getEnvironmentVariableCollection is not a function
      	at _.activate (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:440573)
      	at /home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2386
      	at Array.map (<anonymous>)
      	at g.activateWorkspace (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2376)]
    ]
    2023-08-18 08:11:44.296 [error] Failure during activation. [TypeError: this.context.getEnvironmentVariableCollection is not a function
    	at _.activate (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:440573)
    	at /home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2386
    	at Array.map (<anonymous>)
    	at g.activateWorkspace (/home/patrick/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2376)]
    2023-08-18 08:11:44.296 [error] sendStartupTelemetry() failed. [TypeError: this.context.getEnvironmentVariableCollection is not a function
    	at _.activate (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:440573)
    	at /home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2386
    	at Array.map (<anonymous>)
    	at g.activateWorkspace (/home/user/.vscode/extensions/ms-python.python-2023.15.12221007/out/client/extension.js:2:2376)]
    2023-08-18 08:11:44.829 [info] Starting Pylance language server.
    2023-08-18 08:11:45.515 [info] LINTING: Skipping linting from Python extension, since Flake8 extension is installed and enabled.
    
    • When setting "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"] an additional line 2023-08-18 08:15:42.235 [info] Experiment 'pythonTerminalEnvVarActivation' is inactive shows up in the log, but otherwise everything is unchanged.

    Indeed, this error does not show up anymore if I switch to the release version v2023.14.0. The actual issue that "nothing" is working properly (e.g. no auto-completion, unable to jump to definitions via ctrl+click, ... - all the stuff one uses an IDE for) is still there (which was the reason I checked out the prerelease in the first place). So I guess the cause for that is a different issue - but without any error logs anywhere, I guess I'll have to search further myself.

    At least I was able to report some error in the pre-release version then...

  4. karrtikr commented on Aug 18, 2023

    @karrtikr

    The issue was fixed here in the Python extension pre-release, but unfortunately that pre-release is only applicable on VS Code insiders: #21799.

    So I'm making another fix to backport this fix to VS Code stable: #21846. Thanks for reporting!

  5. added
    bugIssue identified by VS Code Team member as probable bug
    needs PRReady to be worked on
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Aug 18, 2023
  6. karrtikr commented on Aug 18, 2023

    @karrtikr

    Patrick Mischke (@Patschke) Please try updating your Python extension to latest pre-release version (with "python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"] still being there), and see if you still run into the issue.

  7. ThibautHH commented on Aug 18, 2023

    @ThibautHH

    I Just ran into the exact same problem, and the error did go away just fine with the latest pre-release version.
    The settings.json line for the experiment does not seem to change anything at first glance (except the actual activation of it, of course).
    However, I am still experiencing the no auto-completion/reference jumping like Patrick Mischke (@Patschke).

    Same x64 Linux kernel and VS Code version on my side.

  8. karrtikr commented on Aug 18, 2023

    @karrtikr

    Thibaut Hebert--Henriette (@ThibautHH) Thanks for verifying. Could you open a new issue for auto-completion using Python: Report Issue command? We'll be happy to have a look.

  9. locked as resolved and limited conversation to collaborators on Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-editor-*User-facing catch-allauthor-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions