-
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
Select a Python Interpreter without modifying the workspace's settings.json #2125
Comments
settings.json
is modified on startup when using pipenv
[I edited your ✉️ ⬆️ to come off as more 😃 and less 😠 ] Yes, VS Code's lack of "workspace-personal" on top of a "workspace-global" config can be a problem in this situation. |
Ha sorry, didn't realize I was coming off as 😠 |
@Tiedye No problem! It was basically phrasing as "this is bad!" can be off-putting because it comes off as a demand instead of a request. |
@Tiedye a work-around for this is to set |
Awesome! That works. Should the issue be left open? Or is this more of a vs-code issue at this point. |
We can leave this issue open to consider coming up with a solution that negates the need to force you to set an environment variable (at worst we could document this for users). As for getting personal workspace settings, I believe there is a VS Code issue on this topic so if you can find it and upvote it then that might help get it implemented. |
microsoft/vscode#15909 for reference |
I'm thinking of using this workaround too as I can easily roll out environment variables to all our devs. The unfortunate thing about it is that the .venv isn't in the default .gitignore in our version of GitHub Enterprise so we'll need to remember to add it to every repo. It is in the public github.com version |
@brettcannon Is that the only workaround or could you opt not to update .vscode/settings.json in some way and still use the Pipenv virtualenv's pythonPath? It's great that VS code is working on a general fix in microsoft/vscode#15909 though. I am wondering however if it is customary for extensions to automatically update a workspace's settings? As settings.json is aimed to be shared amongst team members of a project it becomes problematic if it is updated with individual settings, such as in this issue. |
@thernstig I don't know if there's any customary practice that has been established by the VS Code extension community. For us we do it because there's a visible startup cost in searching for a person's environment, so writing it out short circuits that search. |
@brettcannon Part of the reason I am making that comment is because we had this same discussion for issue #265. There I referred to the issue microsoft/vscode#851 on VS Code, where bpasero (his team started VS Code when it was still called Monaco) made this comment about .vscode/settings.json
In relation to that, I was thinking that polluting .vscode/settings.json with user-specific settings must be some kind of antipattern? Adding specific settings to .vscode/settings.json breaks the convention of sharing workspace specific settings for projects. I think this is a huge issue for teams utilizing this feature. Every user in our project now has to do a |
Here's @egamma response to this issue:
Similar issues: Its not an antipattern, there's just no alternative. Until VSC come up with a solution, we have no choice but use @brettcannon @brettcannon If you disagree, please feel free to change the Temporary solutions:
That's it. Everyone now shares the same
More info on multi-root workspaces can be found here: https://code.visualstudio.com/docs/editor/multi-root-workspaces |
@DonJayamanne I think we should come up with a general solution and document the suggestion as this keeps cropping up. |
@DonJayamanne thank you for the detailed answer, much appreciated. Especially that you supplied multiple workarounds we can use. |
Solution:
Work flow (if
This could be extended for all other settings in python extension, however we'd need a UI for this. Today the UI for editing Which is why I'm proposing this solution be scoped ONLY for the Summary:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
How will this affect e.g. |
With deprecation of |
@kynan we are exposing an API which will give extensions actually more details than they currently get from the path setting along with the ability to be notified when the environment is changed by the user. |
@brettcannon, unfortunately this path is a path to closed ecosystem, as it doesn't do much for external tools, but only extensions will benefit. |
IMHO The correct solution is as follows:
This will give better control and will not break current projets |
I might have multiple projects (multi-root folders) in the same workspace. I would expect the extension to read the first parent's |
This is very annoying and seems like a very easy fix. Python path changes from machine to machine. |
@drozzy if VS Code were to ever support such a config file we would, but trying to support a configuration outside of VS Code's mechanisms is an extra support burden and potentially confusing to users. |
But aren't you guys part of microsoft? |
Doesn't this have a workaround using the following setting, or am I mistaken? "python.experiments.optInto": [
"DeprecatePythonPath - experiment"
] |
@SteelPhase I didn't know about that, I guess it's still experimental. Seems like it's meant exactly for this purpose. Thanks. I'll wait until it's officially released. |
@drozzy being part of Microsoft does not mean we get to tell the VS Code team what to do 😉 . You can go to github.com/microsoft/vscode and open a feature request if you want (although I suspect one already exists so I would check first). @SteelPhase yep, that will get you what you want for now. |
Hi, We would just need an API (or any way) to set the interpreter path of this extension from another extension. |
@kariharju you have a couple of options:
We are actually hoping to have this whole situation resolved in a release or two in a way that should make everyone happy (famous last words, I know 😉). |
Hi, yeah I know these things are not easy to get done. I forgot to upvote #16370 (I came from the "same source" 😉). Basically, we don't care about the internals as much as the fact that we could just somehow get isolated python environments up-n-running with this extension (as pretty much every Python developer using VsCode has this one installed as it is kind of a default). In enterprise-scale automation scenarios having the end-user or even the developer's machine "polluted" by multiple Python installations is a no-go. So not all Python environments are installed on the OS level and having a way to point a Python environment location to this extension would be a crucial thing to have. |
Please see #12313 (comment) for an explanation of the change we are slowly rolling out to users to address this. |
…Code changes See: microsoft/vscode-python#2125 microsoft/vscode-python#12313 (comment) microsoft/vscode-python#7805 https://github.com/microsoft/vscode-python/wiki/AB-Experiments/0c052a89db9a175b5ec0942e9fcf687fd87af323 Doing it on the right branch this time!
Be default, a local pipenv environemnt is searched for and if found, is marked as the python interpreter. But it also then adds a line to
settings.json
indicating the path for the virtual environment which can cause issues for configs shared among a team. Thepython.pythonPath
variable will not be constant for each user working on the repo (eg"python.pythonPath": "/home/daniel/.local/share/virtualenvs/ontariofresh_backend-NQNAEc6t/bin/python"
, note my home directory in the path) and thus prevents thesettings.json
file from being committed to the remote repository.Ideally, it would behave just as it does now, but just implicitly sets the python interpreter as the one found without explicitly writing it out to
settings.json
.Environment data
Actual behavior
The installed pipenv virtual environment is found and selected as the python interpreter and the path to that environment is added to
settings.json
.Expected behavior
The installed pipenv virtual environment is found and selected as the python interpreter and the path to that environment is not added to
settings.json
.The text was updated successfully, but these errors were encountered: