question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Details on the A/B experiment removing `python.pythonPath` support

See original GitHub issue

Summary of the situation

For security reasons we need to not automatically trust the python.pythonPath setting when it originates from a .vscode/settings.json file in a workspace. We also had a long-standing request to not write a user’s environment path to .vscode/settings.json to allow for it to be committed to version control without be specific to any one user’s machine.

We set up an A/B experiment to measure impact on users in dropping support for python.pythonPath. This issue is a response from users who were negatively impacted. We are working with various teams within Microsoft to try and come up with a situation where we can bring back some semblance of the old semantics while still providing the level of security and safety we need to.

To stay updated on our work to resolve the situation, please feel free to subscribe to this issue – there’s a “Subscribe” button in the right column – and we will post updates to this issue as things develop.

Related issues:

Wiki: https://github.com/microsoft/vscode-python/wiki/AB-Experiments

Opting out of the experimental semantics

To opt out of the experiment, you can set “python.experiments.optOutFrom” to either the specific experiment or to ["All"] to opt out of all experiments. See https://github.com/microsoft/vscode-python/wiki/AB-Experiments#faq for more details.

Original post

_Originally posted by @zor-el in https://github.com/microsoft/vscode-python/pull/12002#issuecomment-643187987_

I’m posting this coming from #2125 because that issue is referenced from the announcing blog post.

Complete removal of python.pythonPath from the settings is a massively breaking change that IMO isn’t warranted by the #2125 issue that has been used to justify it in the above blog post. (This change has certainly been breaking things left and right for me.) The explanation in that blog post’s comment that “it can be useful” doesn’t invalidate my argument. A breaking change is harmful, so it should be significantly outweighed by a benefit that cannot by obtained otherwise. This is not the case here though, IMO.

Although it is true that pythonPath would likely be different for different people, I’d argue that is true for the entire (or most of) .vscode/settings.json. For example, extensions can and do store settings in .vscode/settings.json that may just as well conflict with other users.

Settings are not generally transferable from user to user and from machine to machine, so there is little point in sharing them. In those cases that one would want to share them, one would certainly want to separate transferable from non-transferable settings.

Note the OP’s issue wasn’t the existence of python.pythonPath, but the unsolicited modification of .vscode/settings.json, which sneaks in non-transferable content into (in their case) shared settings.

Apparently the underlying issue is the lack of means for separation of transferable from non-transferable settings. That separation is inadequately addressed by removal of pythonPath (it is a general issue, not one specific to Python). The concrete issue #2125 is not about pythonPath removal either but about unsolicited modification of .vscode/settings.json. That is just as inadequately addressed by mere removal of pythonPath (IMO it could have been solved without breaking everybody’s settings).

Question: Why can we not keep python.pythonPath for backward compatibility and simply ask the user for permission to overwrite it (and hint at the fact that the setting may not be transferable)?

Perhaps even the experiment’s pythonPath caching behavior could remain intact, but an explicit pythonPath setting could take precedence?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:46 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
fredvdcommented, Jul 15, 2020

And on topic: I use VS code to work on projects where we use zc.buildout. It’s common practice to have a virtualenv inside every project folder to have an isolated environment. We have even some tooling which can generate/modify the settings.json.

I was never able (since 2019) to get VS code to pick up the correct virtualenv / venv Python automatically. That was until I started setting my pythonPath explicitly in the settings.json using:

"python.pythonPath": "${workspaceFolder}/bin/python3.7"

The settings.json can be shared with other team members or put in VCS as we all have our Python inside the project and everything is relative/inside the workspace. zc.buildout also generates a list with paths of the used Python modules, which are written to an .env file. actually this is also called PYTHONPATH . In my settings.json I use python.envFile for that:

"python.envFile": "${workspaceFolder}/.vscode/.env",

I agree with most other peoples feedback here: if you want to improve the automatic detection (which worked very poorly so far in my experience), do this by all means. But why remove a setting which is used actively by a significant group of users who scaffold the IDE settings using automation tools? Without any fallback?

5reactions
FlyingRedDonkeycommented, Oct 23, 2020

I don’t like this change.

It would have been preferable if a better workaround to the original issue was released first before breaking python.pythonPath. Or perhaps just leave it be; it ain’t hurtin’ nobody by existing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Settings Reference for Python - Visual Studio Code
The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with. For general information...
Read more >
python - PyCharm and PYTHONPATH - Stack Overflow
You need to go to the Main PyCharm Preferences, which will open up a separate window. In the left pane, choose Project:... >...
Read more >
1. Command line and environment — Python 3.11.1 ...
path (allowing modules in that directory to be imported as top level modules). Raises an auditing event cpython.run_command with argument command . -m ......
Read more >
Configure a Python interpreter | PyCharm Documentation
Configuring an existing Python interpreter ... When PyCharm stops supporting any of the outdated Python versions, the corresponding Python ...
Read more >
Manage Python environments and interpreters - Visual Studio ...
Fix or delete invalid environments. If Visual Studio finds registry entries for an environment, but the path to the interpreter is invalid, then ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found