-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
python.defaultInterpreterPath doesn't always work (plus feedback/concerns about DeprecatePythonPath experiment) #12622
Comments
@ex-nerd The steps to reproduce you mentioned didn't do it for me. For me the new interpreter was picked up correctly. What I did was,
Note we do not cache interpreter setting values, and look up the settings everytime. We do cache the environments discovered, but not the setting.
I suspect you have this interpreter set in workspace settings (which are now stored in VSCode internal storage) instead of user setting Try to clear the value stored in workspace settings using |
@karrtikr If by "in workspace settings" you mean that the default interpreter path and all other settings are stored in If you're unable to reproduce this by using global settings, then it sounds like this is definitely a bug if vscode handles the workspace settings differently. |
No I don't mean that at all. Please have a look at the wiki I linked earlier to see how settings are stored. And try the steps I mentioned. User and workspace settings are two entirely different things. |
@karrtikr As far as I can tell, the wiki is saying that my situation is an intentional choice to break projects that use workspace-specific interpreters controlled by the workspace itself:
I'm trying to use |
You cannot use a user setting in workspace scope. Like the wiki mentions, if you want to configure workspace-specific interpreters, use the Please try the solution I mentioned earlier with clearing workspace settings and then get back to me. |
@karrtikr Yes... Granted, part of this is confusion around the experiment info page I was sent to when vscode notified me that I'd been opted in (which to my recollection didn't mention that There also seems to be something different between using a pyenv environment from its main location in But you keep answering me as if I'm not specifically reporting it as a bug that I can't control the python interpreter from my workspace settings like I can if I opt out of this experiment and revert to previous behavior. This new experimental behavior previous convention and forces users to manually type in a path they may not know every time the project changes its interpreter settings (because for some reason it doesn't show up in the picker .. and I can't even use something like |
Yes, apologies for the confusion. The previous wiki wasn't clear enough about the details, I recently mended it.
I wanted to first clear up the first part where you mentioned you "believe there is buggy behavior in how We realize that the new experiment would take away the ability to share interpreter paths in workspace settings, which is why I wasn't talking about it like it's a bug because the behavior you see is expected from dev-perspective. If interested, you can have a look at the few issues which motivated this solution. We have marked this issue as "needs decision" to make sure we have a conversation about your thoughts, after which we'll get back to you. |
Thanks, and that's fair. The original wording I used was based on the unclear wording in the wiki about the use of I think much of this could be solved by making Though a better idea might be to add a different workspace-specific setting
|
Today I just found myself in the exact same scenario as @ex-nerd reports. Our team also uses direnv and sets a different Python environment for each project, which is always relative to the workspace directory. We have always used the Yes, we can make our developers to manually select an environment in each one of their projects, but this is not intuitive (sometimes the required environment is not shown even though it's in the So, yes, we understand the need to allow a user setting for all the scenarios where Python paths are not shared, but I don't think that disabling the existing behaviour is a good idea as it breaks compatibility with some use cases and, even worse, it forces teams to waste work time trying to discover how this must be done now. This should be as easy as testing the |
Please don't implement this feature. Or at least allow for defaultInterpreterPath to be set at the workspace level, many projects I've worked on manage Python interpreters internally to the project - for the exact same reasons stated as the motivation of this experiment "teams that don’t use the same OS, or simply work with interpreters that don’t share the same path" - but more then that often the interpreter is managed in the project precisely to isolate the project from system python. It is a major inconvenience to need to explicitly set this every time - and looks to be error prone as it isn't clear that it is not set or that it needs to be set differently. |
According to https://github.com/microsoft/vscode-python/wiki/AB-Experiments this is now available in workspace scope. Is that correct? |
Yep, this can now be closed. |
bug
After finding myself one of the 4% opted into the DeprecatePythonPath experiment, I've noticed some inconsistency in how the interpreter path is handled, and believe there is buggy behavior in how
python.defaultInterpreterPath
is implemented. The replication is as follows:python.defaultInterpreterPath
to your preferred python path (e.g. a local pyenv installation of 3.7.2)python.defaultInterpreterPath
to point to the new interpreter pathActual results:
vscode has now detected that the interpreter it had been using is no longer available, and is now in a state where there is no interpreter configured, and a user has to manually specify one.
Expected results:
vscode should detect that the cached state of the interpreter is incorrect (which it seems to do) but instead of "prompting" (it's hardly a "prompt") the user to select a new interpreter, it should fall back to the configured
python.defaultInterpreterPath
(after all, that's what a default is for).Additionally:
Other thoughts
I work on a team that uses direnv to enforce a specific environment for each of our projects. This includes maintaining different versions of python in the project directories based on where these will be deployed (e.g. App Engine has access to 3.8 but App Engine Flex only 3.7.2), and allowing us to rebuild these environments on the fly, test out different versions on different branches (e.g. when Flex gets 3.8 we'll make a branch to test that but still need to switch back and forth to work on "known stable" branches).
Since it seems likely from comments on #2125 that this experiment will become permanent, my initial solution to both of these was to add something the following to the shared
settings.json
files in each repository to ensure that everyone is opted in to this experiment and will default to the proper python instance:However, due to the aforementioned bug, this means that many of our projects open up the "first" time with no interpreter set (seemingly conflicting with whatever value was cached before the experiment was activated), and that any attempts to upgrade or switch python interpreters for a specific project will mean the user has to manually specify the python interpreter every time he/she switches between branches with different python versions activated (and know which version to select, which means cracking open
settings.json
or our.envrc
to see). This is not an improvement as far as usability goes.So for now, I've opted my team out of this experiment (thanks for adding that option) until the usability issues have been resolved, and/or there are options that once again allow for project settings to control the python path:
The text was updated successfully, but these errors were encountered: