microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

Stuck on "Reactivating terminals" - Failed to resolve env #23922

Closed DrShushen closed 2 days ago

DrShushen commented 3 months ago

Type: Bug

Since the latest update of VSCode Insiders, the Python extension fails to launch (no syntax highlighting etc.), there is a permanent "Reactivating terminals..." in the status bar, and when I select OUTPUT > Python, I see the following error:

2024-08-07 18:35:35.873 [error] sendStartupTelemetry() failed. s [Error]: Failed to resolve env "/mnt/data-linux/miniconda3"
    at ae (/home/user/.vscode-insiders/extensions/ms-python.python-2024.12.2-linux-x64/out/client/extension.js:2:1968174)
    at oe (/home/user/.vscode-insiders/extensions/ms-python.python-2024.12.2-linux-x64/out/client/extension.js:2:1966134)
    at Immediate.<anonymous> (/home/user/.vscode-insiders/extensions/ms-python.python-2024.12.2-linux-x64/out/client/extension.js:2:1962428)
    at processImmediate (node:internal/timers:478:21) {
  code: -4,
  data: undefined
}

Not sure if it is related to the fact that my conda environments are on a mounted partition under /mnt/.

I have tried with Python pre-release and Release versions of the extension, and the issue happens in both cases.

The issue does not happen in vanilla VSCode (non Insiders)


VSCode info

Version: 1.93.0-insider
Commit: d4c4e690b9f1e70291da9a46c5c8ac5ebfbda81a
Date: 2024-08-07T05:03:47.999Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.8.0-39-generic snap

System info:

## Report details
- **Date generated:**                              2024-08-07 18:41:37

## Hardware Information:
- **Hardware Model:**                              ASUS ROG STRIX B460-H GAMING
- **Memory:**                                      64.0 GiB
- **Processor:**                                   Intel® Core™ i9-10900K × 20
- **Graphics:**                                    NVIDIA GeForce RTX™ 3090
- **Disk Capacity:**                               7.0 TB

## Software Information:
- **Firmware Version:**                            1610
- **OS Name:**                                     Ubuntu 24.04 LTS
- **OS Build:**                                    (null)
- **OS Type:**                                     64-bit
- **GNOME Version:**                               46
- **Windowing System:**                            X11
- **Kernel Version:**                              Linux 6.8.0-39-generic

Tried with Python extension:

Extension version: 2024.12.2 VS Code version: Code - Insiders 1.93.0-insider (d4c4e690b9f1e70291da9a46c5c8ac5ebfbda81a, 2024-08-07T05:03:47.999Z) OS version: Linux x64 6.8.0-39-generic snap Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz (20 x 4899)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off| |Load (avg)|0, 0, 0| |Memory (System)|62.70GB (50.98GB free)| |Process Argv|--no-sandbox --force-user-env --crash-reporter-id 5e036db4-7975-4920-936d-345ce33b1cab| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 vsaa593:30376534 py29gd2263:31024238 c4g48928:30535728 962ge761:30841072 pythongtdpath:30726887 welcomedialog:30812478 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 dsvsc015:30821418 pythonregdiag2:30926734 pythonmypyd1:30859725 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 cppperfnew:30980852 pythonait:30973460 g316j359:31013175 a69g1124:31018687 dvdeprecation:31040973 dwnewjupytercf:31046870 2f103344:31071589 legacy_priority:31057981 nativerepl1:31104042 refactort:31084545 pythonrstrctxt:31093868 flightc:31105041 wkspc-onlycs-c:31111717 nativeloc1:31111755 wkspc-ranged-c:31111712 cf971741:31111988 fcdif617:31111928 ```
DrShushen commented 3 months ago

More info for debugging this.

I have installed the exact same version of VSCode Insiders but with apt rather than snap, and this issue no longer happens.

See below the version info (the only difference is OS: Linux x64 6.8.0-39-generic vs OS: Linux x64 6.8.0-39-generic snap.

Version: 1.93.0-insider
Commit: d4c4e690b9f1e70291da9a46c5c8ac5ebfbda81a
Date: 2024-08-07T05:03:47.999Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.8.0-39-generic

Python extension version: v2024.13.2024080701 (pre-release)

zhao-kun commented 3 months ago

Same problems. Except for the difference in the OS version, my VsCode insider version is the same. Version details:


Commit: d4c4e690b9f1e70291da9a46c5c8ac5ebfbda81a
Date: 2024-08-07T05:03:47.999Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Linux x64 5.10.222-1-MANJARO```
SanBingYouYong commented 3 months ago

Just encountered this on my win11 laptop locally, but when connected via ssh to remote linux server everything is fine.. both environments are set up with miniconda3

2024-08-16 17:02:53.403 [error] Failure during activation. s [Error]: Failed to resolve env "C:\\Users\\13152\\miniconda3"
    at ae (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1968174)
    at oe (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1966134)
    at Immediate.<anonymous> (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1962428)
    at processImmediate (node:internal/timers:478:21) {
  code: -4,
  data: undefined
}
2024-08-16 17:02:53.403 [error] sendStartupTelemetry() failed. s [Error]: Failed to resolve env "C:\\Users\\13152\\miniconda3"
    at ae (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1968174)
    at oe (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1966134)
    at Immediate.<anonymous> (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1962428)
    at processImmediate (node:internal/timers:478:21) {
  code: -4,
  data: undefined
}

And this is not an Insider version:

Version: 1.92.2 (user setup)
Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
Date: 2024-08-14T17:29:30.058Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Update: After leaving it to run for a solid period of time (when I come back) the problem is mysteriously gone. I have no clue what is going on in the whatever backend this might involve but I do feel bad to somehow lose control of my workspace.

karthiknadig commented 3 months ago

A few things to try: [Option 1] Try the command Python: Clear Cache and re-load from the command 🎨. I suspect there might be paths in cache that it is trying to find and somehow failing. [Option 2] Try setting python.locator to native and reload. This will use a newer detector for python that should work faster. But, be sure to be on latest stable (2024.12.3 or greater) to get this.

corneliusroemer commented 3 months ago

Possibly same issue as this: #23963 (I encountered on macOS ARM)

Restarting my computer helped for me. My locator is already set to "native".

@karthiknadig did you maybe mean switch from native to js? The problem could be with native rather than js. At least per #23956 this helped some.

SanBingYouYong commented 3 months ago

Just encountered this on my win11 laptop locally, but when connected via ssh to remote linux server everything is fine.. both environments are set up with miniconda3

2024-08-16 17:02:53.403 [error] Failure during activation. s [Error]: Failed to resolve env "C:\\Users\\13152\\miniconda3"
    at ae (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1968174)
    at oe (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1966134)
    at Immediate.<anonymous> (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1962428)
    at processImmediate (node:internal/timers:478:21) {
  code: -4,
  data: undefined
}
2024-08-16 17:02:53.403 [error] sendStartupTelemetry() failed. s [Error]: Failed to resolve env "C:\\Users\\13152\\miniconda3"
    at ae (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1968174)
    at oe (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1966134)
    at Immediate.<anonymous> (c:\Users\13152\.vscode\extensions\ms-python.python-2024.12.3-win32-x64\out\client\extension.js:2:1962428)
    at processImmediate (node:internal/timers:478:21) {
  code: -4,
  data: undefined
}

And this is not an Insider version:

Version: 1.92.2 (user setup)
Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
Date: 2024-08-14T17:29:30.058Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Update: After leaving it to run for a solid period of time (when I come back) the problem is mysteriously gone. I have no clue what is going on in the whatever backend this might involve but I do feel bad to somehow lose control of my workspace.

This issue occurs again and this time I tried the solution @corneliusroemer mentioned (switching native/js) and switching locator from native to js solved this issue for me after restarting vscode.

austinmw commented 2 months ago

I got the same error. Fresh install of VSCode (not insiders) on silicon mac. The above solution fixed it:

"python.locator": "js"

Not sure why this is broken, but not happy I wasted over an hour on this..

corneliusroemer commented 2 months ago

Thanks for sharing this worked for you @austinmw. I made a Stackoverflow question and answer in the hope more people quickly find the workaround until there's a proper fix: https://stackoverflow.com/questions/78886125/vscode-python-extension-stuck-on-reactivating-terminals/78886126#78886126

Update: wow the Q&A has already 135 views in just 11 hours - this suggests that a lot of people are getting this error. @karthiknadig would be great if someone at MSFT could look at this, I think. Hope the ping is ok in this case.

karthiknadig commented 2 months ago

There should be a mitigation pushed out in pre-release.

related: https://github.com/microsoft/vscode-python/issues/23982

anthonykim1 commented 2 months ago

Are folks still suffering from this on the latest pre-release version? Just got another issue from https://github.com/microsoft/vscode-python/issues/24026 so I want to make sure. Thought this was resolved based on:https://github.com/microsoft/vscode-python/issues/23982#issuecomment-2311733151

corneliusroemer commented 2 months ago

@anthonykim1 I think it's impossible to say - report #24026 you linked to is insufficient to allow any conclusions - it's missing version of extension that's being used.

anthonykim1 commented 2 months ago

@corneliusroemer Great point - Are folks using 2024.14.0 https://github.com/microsoft/vscode-python/releases/tag/v2024.14.0 or the latest pre-release of Python extension experiencing this 'reactivating terminals' problem?

nurpax commented 2 months ago

FWIW I just hit this with an updated VSCode (not insiders version):

Version: 1.93.0 (system setup)
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.19045

Found the fix through the SO post, changing the "python.locator" to "js" helped.

corneliusroemer commented 2 months ago

@nurpax thanks for the report! What's your Python extension version?

nurpax commented 2 months ago

Looks like Python is at v2024.14.0. Pylance is v2024.9.1 in case that's relevant here.

corneliusroemer commented 2 months ago

@anthonykim1 something seems to have happened recently making this bug more frequent for folks - the views on my Stackoverflow question have shot up like crazy in the last day, I think from 600 to 900, and the question has been open for 23 days. So the view rate might be the highest it has ever been.

Adding a screenshot so we have a trackrecord:

-    0  views on 2024-08-19Z00:31:00 (UTC)
-  558  views on 2024-09-05Z23:04:58 (UTC) [  33 views/day since previous snapshot]
-  947  views on 2024-09-11Z15:54:21 (UTC) [  65 views/day since previous snapshot]
-  986  views on 2024-09-11Z19:28:00 (UTC) [ 262 views/day since previous snapshot]
- >1.5k views on 2024-09-16Z13:17:00 (UTC) [~100 views/day since previous snapshot]
- <2.5k views on 2024-09-20Z20:19:00 (UTC) [<210 views/day since previous snapshot]
- >3.5k views on 2024-09-30Z06:46:00 (UTC) [>100 views/day since previous snapshot]

See: https://web.archive.org/web/20240000000000*/https://stackoverflow.com/questions/78886125/vscode-python-extension-loading-forever-saying-reactivating-terminals

LeslieTiangang commented 2 months ago

I got the same error. Fresh install of VSCode (not insiders) on silicon mac. The above solution fixed it:

"python.locator": "js"

Not sure why this is broken, but not happy I wasted over an hour on this..

It really saves me!

khood5 commented 1 month ago

"python.locator": "js"

This helped me as well

WBeard4 commented 1 month ago

"python.locator": "js"

Issue still occurring, this still resolved it.

Arch881010 commented 1 month ago

+1

fanesz commented 1 month ago

"python.locator": "js"

It works!, put it to vscode settings.json

corneliusroemer commented 1 month ago

The issue seems to be resolved in the latest release version 2024.14.1 - try updating before changing the user settings and report back here if the update doesn't resolve the issue as that would be interesting to know (we all know that prior versions had the bug by now, there's no information in that).

karthiknadig commented 1 month ago

For anyone running into this issue. Can issue with the latest insiders or stable, please try and find this binary and run the following.

Binary: "C:\Users\kanadig.vscode-insiders\extensions\ms-python.python-2024.15.2024092702-win32-x64\python-env-tools\bin\pet.exe"

In the logs you may see an error like this:

[error] Failure during activation. s [Error]: Failed to resolve env "C:\\ProjectDeps\\miniconda3"

Run this for the terminal:

C:\Users\kanadig\.vscode-insiders\extensions\ms-python.python-2024.15.2024092702-win32-x64\python-env-tools\bin\pet.exe resolve C:\\ProjectDeps\\miniconda3

Either you will get an error or a result like this: image

Please share, the error. Please also share the Output from Output > Python Locator.

corneliusroemer commented 1 month ago

@karthiknadig what to do for those not on windows? your command assumes people are on windows if I don't misunderstand.

karthiknadig commented 1 month ago

The same one exists for all other platforms. It would be something like this:

~/.vscode-insiders/extensions/ms-python.python-2024.15.2024092702-<platform>\python-env-tools\bin\pet resolve <minoconda-path>

<platform>: win32-x64, win32-arm64, linux-x64, linux-arm64,linux-armhf, darwin-x64, darwin-arm64, alpine-x64, alpine-arm64

SaschaCowley commented 1 month ago

I also just ran into this, only I'm not using Conda. From the logs, it looked like vscode-python was trying to activate the wrong virtual environment. Running Python: Clear Cache and Reload Window from the command palette seems to have fixed the issue.

System info ``` Version: 1.94.0 (user setup) Commit: d78a74bcdfad14d5d3b1b782f87255d802b57511 Date: 2024-10-02T13:08:12.626Z Electron: 30.5.1 ElectronBuildId: 10262041 Chromium: 124.0.6367.243 Node.js: 20.16.0 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22635 ms-python.python: 2024.16.0 ```
Log output ``` 2024-10-04 15:36:09.721 [info] Experiment 'pythonRecommendTensorboardExt' is active 2024-10-04 15:36:09.722 [info] Experiment 'pythonSurveyNotificationcf' is active 2024-10-04 15:36:09.722 [info] Experiment 'pythonTerminalEnvVarActivation' is active 2024-10-04 15:36:09.722 [info] Experiment 'pythonTestAdapter' is active 2024-10-04 15:36:09.722 [info] Native locator: Refresh started 2024-10-04 15:36:09.722 [info] Default formatter is set to charliermarsh.ruff for workspace d:\projects\nvda 2024-10-04 15:36:09.731 [error] Python Extension: interpreterManager.refresh [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } 2024-10-04 15:36:10.065 [info] > pyenv which python 2024-10-04 15:36:10.065 [info] cwd: . 2024-10-04 15:36:10.180 [error] [ 'getActivatedEnvironmentVariables, Class name = j, completed in 0ms, has a falsy return value, Arg 1: , Arg 2: undefined, Arg 3: undefined, Arg 4: "C:\\\\Program Files\\\\PowerShell\\\\7\\\\pwsh.exe"', [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } ] 2024-10-04 15:36:10.180 [error] Failed to apply terminal env vars undefined [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } 2024-10-04 15:36:10.180 [error] [ 'Failed to activate a workspace, Class name = v, completed in 471ms, has a falsy return value, Arg 1: , Arg 2: {"started":1728020169581}, Return Value: undefined', [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } ] 2024-10-04 15:36:10.180 [error] Failure during activation. [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } 2024-10-04 15:36:10.180 [error] sendStartupTelemetry() failed. [l [Error]: Failed to resolve env "D:\\projects\\nvda-pr\\.venv" at ae (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2052229) at oe (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2050189) at Immediate. (c:\Users\SaschaCowley\.vscode\extensions\ms-python.python-2024.16.0-win32-x64\out\client\extension.js:2:2046483) at process.processImmediate (node:internal/timers:483:21)] { code: -4, data: undefined } 2024-10-04 15:36:10.192 [info] Native locator: Refresh finished in 558 ms ```
karthiknadig commented 1 month ago

@SaschaCowley can you also share the output from “Python locator”. If you still have it.

Silverwolf-x commented 1 month ago

@SaschaCowley Thanks! It helps a lot!

karthiknadig commented 1 month ago

If you are using conda and run into this issue, please try the pre-release v2024.17.2024101402 .

github-actions[bot] commented 2 days ago

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!