Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exposed API updateActiveEnvironmentPath outside workspace #25045

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

Closed
Ma-Shell opened this issue May 9, 2025 · 1 comment
Closed

Exposed API updateActiveEnvironmentPath outside workspace #25045

Ma-Shell opened this issue May 9, 2025 · 1 comment
Labels
feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team

Comments

@Ma-Shell
Copy link

Ma-Shell commented May 9, 2025

The public API of vscode-python exposes the function environments.updateActiveEnvironmentPath.
This function only works, when operating within a workspace. If I open VSCode with just a single Python file and try to execute this function, the output-log shows:
[error] Cannot update workspace settings as no workspace is opened
However, switching over the builtin-menu in the status bar is possible, even when not in a workspace.

Background info and reproducible example:
I wrote an extension related to this feature request: #24916.
As suggested in #21783, my extension https://github.com/Ma-Shell/uvscode uses the exposed updateActiveEnvironmentPath-function to automatically switch the interpreter for PEP 723 compatible scripts based on the currently edited file to the result of uv python find --script. This works, when opening a folder but not when opening individual files without a workspace.
The extension is currently not on the extensions marketplace and needs to be compiled manually to use. The error message stated above is not displayed in the debugger but within the instance that has the extension loaded, when selecting "Python" in the Output console.

@Ma-Shell Ma-Shell added the feature-request Request for new features or functionality label May 9, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label May 9, 2025
@karthiknadig
Copy link
Member

@Ma-Shell That API will eventually be replaced by APIs from https://github.com/microsoft/vscode-python-environments extension.

That extension supports setting Python for PEP-723 style scripts out of the box. Not only for uv but for any environment manager. It uses a entirely different mechanism for this. And a way to notify tooling that depends on env paths that those changed.

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants