Skip to content
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

Provide a way to explicitly tell the extension to automatically pick interpreter from PATH #12665

Closed
jraygauthier opened this issue Jun 30, 2020 · 4 comments
Labels
feature-request Request for new features or functionality

Comments

@jraygauthier
Copy link

jraygauthier commented Jun 30, 2020

Some context

Currently using nix to create versionable environments for my projects. I enter the environment (using nix-shell) and then launch code from inside this environment. The environment provides a python interpreter via the PATH environment variable. This python interpreter comes packed with all the python projects dependencies. The interpreter is located in the nix store: /nix/store/4qp2kldp8pn912gdsiawxkvyh6dajlpw-python3.5-python35-interpreter/bin/python. This path changes for any tiny change to the interpreter of its dependencies (including system dependencies of the python interpreter or any of the python dependencies which are also delivered by nix).

The problem

At some point in the past (before the extension being taken over by ms) specifying python.pythonPath = "python" was enough for nix env interpreter being picked by vscode. However, at some point it stopped working properly (selecting the python from the system or venv instead of PATH). After some search and experimentation, I discovered that specifying instead python.pythonPath": "${env:NIX_PYTHON_INTERPRETER}" was a workaround.

This is however a bit awkward and redundant as it forces me to define the NIX_PYTHON_INTERPRETER environment variable as part of the shellHook of each of my nix env.

Also, for most projects I work on, all developers use nix and as such we generally like to be explicit that for this particular project, we want vscode to automatically pick the python interpreter from PATH (as provided by the nix env). This is why we generally set ${env:NIX_PYTHON_INTERPRETER} in the project's .vscode/settings.json but would have instead preferred to only specify python.pythonPath = "python" or any other expression that tells vscode to take the interpreter from PATH.

As a sideline, if I understood well, I learn that this might no longer be possible to specify this settings as part of .vscode/settings.json nor workspace settings. See Queries about moving workspace pythonPath setting into VSCode storage · Issue #12313 · microsoft/vscode-python for some context.

Note that this issue is really about a way to reliable pick the interpreter from PATH and the possibility to be explicit about it and ideally that his can be specified on a per project basis, optionally version controlled.

@jraygauthier jraygauthier added triage-needed Needs assignment to the proper sub-team feature-request Request for new features or functionality labels Jun 30, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jul 2, 2020
@brettcannon
Copy link
Member

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

@CatNofishing
Copy link

good suggestion

@luabud
Copy link
Member

luabud commented Aug 26, 2020

Thanks for the suggestion! We talked about it with the team and we have unfortunately decided we will not be moving forward with this idea. We think there isn't an enough widespread need for this to warrant the maintenance cost for the feature.

@luabud luabud closed this as completed Aug 26, 2020
@ghost ghost removed the needs decision label Aug 26, 2020
@simonrainerson
Copy link

Hello, at my workplace we are switching over to use nix for our development environments and we just discovered the same issue with using vscode. This feature would be very helpful so we can use different versions of python in different circumstances.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants