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

VirtualEnv in Python doesn't trigger postactivate #9917

Closed
1st opened this issue Feb 5, 2020 · 4 comments
Closed

VirtualEnv in Python doesn't trigger postactivate #9917

1st opened this issue Feb 5, 2020 · 4 comments
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality

Comments

@1st
Copy link

1st commented Feb 5, 2020

I've a file with post activate logic located at ~/.virtualenvs/env_name/bin/postactivate that can contain something like this:

export ENV_NAME=local
cd ./src

It works file if I use workon env_name command from Virtual Env Wrapper.

But when I create a new terminal inside VSCode it activate the env like this:
source /Users/anton/.virtualenvs/env_name/bin/activate

And problem here that postactivate script isn't run.

It will be good to use virualenvwrapper inside VS Code or alternatively add extra commands that will be executed after activation of the python virtual env.

If it's already a way how to execute additional script after activation of the virtual env - please let me know. I didn't find such property in VS Code settings file.

Thank you

@1st 1st added data science bug Issue identified by VS Code Team member as probable bug labels Feb 5, 2020
@1st 1st changed the title virtualEnv in Python doesn't trigger postactivate VirtualEnv in Python doesn't trigger postactivate Feb 5, 2020
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Feb 5, 2020
@karthiknadig
Copy link
Member

We don't support workon. At this point this is a feature request.

@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality needs decision and removed bug Issue identified by VS Code Team member as probable bug labels Feb 5, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 5, 2020
@karthiknadig
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.

@1st
Copy link
Author

1st commented Feb 6, 2020

@karthiknadig Maybe you know how to make it possible to execute some script that sets env variables in the new terminal every time when I open a new terminal inside VS Code? Currently it only activates the virtual env, but I want to run an additional shell script that will run some additional logic.

As a way to do this - you can add a post_activate_script option to the settings. Maybe you already have something like this available via settings?

I’ve found that it’s a trigger for “.env” file that is in the project root directory. But it just sets variables. I need also to change a working for to something like “src” inside the root dir. This way every time when I will open a new terminal window it will set all necessary env variables and will switch directory to “src”, as well it will activate the virtual env inside the terminal.

Need your help in solving such situation with the currently available options. And will be good to make a generic approach to simplify this thing for future.

@luabud
Copy link
Member

luabud commented Mar 25, 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.

As for a workaround, we unfortunately don't have one :( perhaps you could turn off automatic activation of environments and do that process manually?!

FWIW #8870 could provide a workaround for this if we implement it.

@luabud luabud closed this as completed Mar 25, 2020
@ghost ghost removed the needs decision label Mar 25, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants