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 ability to scope EnvironmentVariableCollection to a specific terminals #138109

Closed
DonJayamanne opened this issue Nov 30, 2021 · 6 comments
Assignees
Labels
*as-designed Described behavior is as designed info-needed Issue requires more information from poster terminal Integrated terminal issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@DonJayamanne
Copy link
Contributor

Currently EnvironmentVariableCollection applies to all terminals.
I'd like the ability to have custom env variables for specific Terminals, not all.

Use case
Here's what we have today, Data Scientists don't necessarily work on one Python environment. They use multiple Python environments in the same VS Code Workspace, by using multiple notebooks that use different environments (we've had to introduce a lot of changes to make it easy for Data Scientist to work with these different versions).

I created the extension Python Env Manager that allows users to create terminals for each Python environment. This works today. However I cannot use EnvironmentVariableCollection as this applies to all Terminals (I need one that applies to just the terminal created by my extension).

Thus, I'd like for this API to apply to a specific terminal that was created by the extension for a specific Python Environment. E.g. if users create a terminal for Conda Environment A, i'd like for env variables from Conda A to be applied here and not all other terminals.

Also my concern is, if the Python extension adopts this API, then the extension Python Env Manager will break as all of the Env variables will be overwritten when it should not be. However having contextual information about the Terminal would help.

Note: Today Python extnesion doesn't mess with Terminals created by other extensions when they are hidden.

@meganrogge meganrogge added terminal Integrated terminal issues under-discussion Issue is under discussion for relevance, priority, approach labels Dec 1, 2021
@Tyriar
Copy link
Member

Tyriar commented Dec 6, 2021

@DonJayamanne the env var collection is for adding things that you want in everything, like additions to $PATH, adding new ones ($JAVA_PATH), etc. Is there any reason adding a terminal profile or just calling createTerminal and specifying env there wouldn't work for your use case?

@DonJayamanne
Copy link
Contributor Author

Is there any reason adding a terminal profile or just calling createTerminal and specifying

The problem with createTerminal is I have no idea what kind of shell initialization scripts users have. E.g. user could have a lot of code in their bashrc (or other such shell init scripts) that updates the Path variable. Hence, I cannot create a terminal that provides Path variables using the env variables from the vscode process.

Thats basically the problem.
Basically I need a way to update the variables once the shell has been created (initialized) - unless there's another way, that I've completely missed.

@Tyriar
Copy link
Member

Tyriar commented Dec 7, 2021

@DonJayamanne the environment variable collection adds them before the shell is initialized in the same way as createTerminal though, the only way to do something like that is to add your own shell init script (eg. --rcfile) or send text to the shell (which is ugly and might not work)

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Dec 7, 2021
@DonJayamanne
Copy link
Contributor Author

something like that is to add your own shell init script (eg. --rcfile)

Yup, the problem is, I worked then end up changing user setting to get this done. And will need to sort all known shells

or send text to the shell (which is ugly and might not work)

Those is what I'm doing now

Basically both options aren't great.
Sounds like those isn't going to work, at least not for my use case.

@Tyriar
Copy link
Member

Tyriar commented Dec 8, 2021

Hm ok, well I'm going to close this as EnvironmentVariableCollection sets the environment the same as createTerminal. Not sure what the right thing is here. FYI we'll be looking into shell integration soon where we will be setting up our own rcfile for various shells #133084, we might want to coordinate if you're going to try something new around the Python environment.

@Tyriar Tyriar added the *as-designed Described behavior is as designed label Dec 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed info-needed Issue requires more information from poster terminal Integrated terminal issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants
@DonJayamanne @Tyriar @meganrogge and others