-
Notifications
You must be signed in to change notification settings - Fork 102
python bug: "Could not start runtime: failed to resolve interpreter" #7206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
My running hypothesis is we're trying to start the session before the interpreter is resolved, and that's causing problems. This is the error that's thrown:
That |
yeah here's the aforementioned PET error in the python language pack:
|
I switched off PET and can't trigger this error, so we can look around the PET code. |
Okay, I think I've narrowed it down a bit. When we resolve the env here:
There is a chance, depending on a race condition, that this.finder is not the "normal" NativePythonFinder, but instead this "untrusted" NativePythonFinder:Lines 506 to 524 in c264519
That seems to be triggered since I'm opening up a project in an "untrusted" folder originally. I'm not sure what work gets done before vs after I click "trust", but that's the race. |
I can confirm that once I "trust" a parent folder, this problem never seems to happen for any workspaces in that folder. So this problem is probably extremely uncommon, only happening in a very specific scenario for the first time you open a workspace. We'll have to decide whether it's worth putting effort into resolving the race condition, because it seems like it could require some significant messing around in upstream code. As a side note, the PET error above with code -4 seems to be a red herring. While testing in a trusted folder, I was able to open a workspace and successfully resolve and start its venv session at
So this probably just has to do with path expansion and doesn't affect the eventual resolution of the interpreter. We can ignore this red herring. |
I owe a rambling update because I'll be working on a different project for a couple days. Did a LOT more digging; still haven't quite found the root cause but feel closer. Some things that feel important:
|
upstream issue: microsoft/vscode-python#23922 it looks like clearing the cache and restarting has helped folks ⏫ i'm seeing this error pop up in #7141 and #6280 as well |
Nice, thanks for finding that issue! That is definitely the cause of the PET error I mentioned above, and possibly the cause of why I couldn't get your delete/recreate PR to work: #7184 (review) I think the issue with not disposing the PythonRuntimeManager during a trust transition might still be something separate, so #7337 will be a good independent change as well. |
<!-- Thank you for submitting a pull request. If this is your first pull request you can find information about contributing here: * https://github.com/posit-dev/positron/blob/main/CONTRIBUTING.md We recommend synchronizing your branch with the latest changes in the main branch by either pulling or rebasing. --> <!-- Describe briefly what problem this pull request resolves, or what new feature it introduces. Include screenshots of any new or altered UI. Link to any GitHub issues but avoid "magic" keywords that will automatically close the issue. If there are any details about your approach that are unintuitive or you want to draw attention to, please describe them here. --> Addresses #7206. There is a lot of discussion in that issue for context. Basically, I think what was happening is that the `PythonRuntimeManager` was not being correctly disposed when the user trusts a workspace and everything gets deactivated/activated again. After this change, it does get disposed during that flow, and I can't reproduce the bug anymore. ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - Fixed bug in Python startup (#7206) ### QA Notes 1. Create a new project. I used uv: ``` uv init proj cd proj uv venv ``` 2. Open a fresh Positron with no state, but with PET and multiconsole on. I do this with the following: ``` rm -rf ~/.vscode-oss-dev rm -rf ~/.positron-dev mkdir -p ~/.vscode-oss-dev/User echo '{"console.multipleConsoleSessions":true,"python.locator":"native"}' > ~/.vscode-oss-dev/User/settings.json ``` 4. No workspace should be selected. It should start "Discovering interpreters". 5. Open Folder to the `proj` workspace 6. Click "trust" 7. The uv interpreter should successfully open a session. Maybe try this a few times at varying levels of speed.
I've decided to add immediate startup if a user has set `defaultInterpreterPath` global values, after the feedback in #6244. Additionally, the runtime startup sequence was failing with PET, these paths needed to be untildified. This was causing the active interpreter (eg, what is started in Jupyter off the bat) to differ from what was the Positron runtime. ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - #6280 Current runtime is now selected automatically in Jupyter kernels outside of a workspace - #7206 Fixes PET behavior where some environments failed to resolve ### QA Notes
Verified FixedPositron Version(s) : 2025.05.0-103 Test scenario(s)Opened project right after starting and no issues. I tried several times with different projects, no issue |
Uh oh!
There was an error while loading. Please reload this page.
System details:
Positron and OS details:
Positron Dev Version: 2025.05.0 build 0
Code - OSS Version: 1.98.0
Commit: Unknown
Date: Unknown
Electron: 34.2.0
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Darwin arm64 24.3.0
Current commit: 11b1f19
Interpreter details:
Python 3.12.8 managed by
uv
Describe the issue:
Sometimes when I open a workspace quickly, the recommended interpreter tries to start up and fails with error
Could not start runtime: failed to resolve interpreter
. If I try again, it succeeds.Steps to reproduce the issue:
proj
workspace before it finishes discovering.Expected or desired behavior:
A new session should start using the
proj/.venv/bin/python
interpreterWere there any error messages in the UI, Output panel, or Developer Tools console?
Some possibly relevant logs from the developer tools console:
The Console shows
Some relevant logs from Python Locator:
And from Python Language Pack:
I am also pretty sure I saw a telemetry event at some point in the past with this error from PET: https://github.com/microsoft/python-environment-tools/blob/845945b830297a50de0e24020b980a65e4820559/crates/pet/src/jsonrpc.rs#L354
The text was updated successfully, but these errors were encountered: