Skip to content

Exposed API updateActiveEnvironmentPath outside workspace #25045

Open
@Ma-Shell

Description

@Ma-Shell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionalitytriage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions