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

Keep PWD when deactivating venv on nushell (activate.nu) #2745

Closed
dmatos2012 opened this issue Jun 26, 2024 · 2 comments
Closed

Keep PWD when deactivating venv on nushell (activate.nu) #2745

dmatos2012 opened this issue Jun 26, 2024 · 2 comments

Comments

@dmatos2012
Copy link

What's the problem this feature will solve?
deactivateing venv will not change the PWD back to where it was activated

Problem:

mkdir v1 && cd v1
virtualenv venv
overlay use venv/bin/activate.nu

mkdir v2 && cd v2
virtualenv venv
pwd
# v2

Then I remember I had the venv from v1 directory activated, and I do

deactivate

Unexpected behavior: cwd changes to v1

Expected behavior: I would like to stay in v2

Describe the solution you'd like

Stay in the current directory

How to solve?

Currently , the activate.nu, has the alias to deactivate, which can be changed to:

overlay hide --keep-env [ PWD ] activate

In that way, cwd stays in v2 rather than v1.

Alternative Solutions

Additional context
I like to name all my venvs venv becauwe its easy, but i work with multiple a day, so I am constantly switching between them, and I forget to deactivate it, and thus im constantly having to change back to the cwd.

Tbh, I dont know if this will break for other people so not sure if it needs to be a config or what, but yeah wanted to raise an issue first to see if this is a problem for others, and then maybe add the one liner PR.

@dmatos2012 dmatos2012 changed the title Keep PWD when deactivating venv on **nushell** [activate.nu] Keep PWD when deactivating venv on nushell (activate.nu) Jun 26, 2024
@gaborbernat
Copy link
Contributor

We don't do per shell customization, it's all or nothing.

For a change this impactful you'd need CPython venv but in first, so create an issue there.

@pfmoore
Copy link
Member

pfmoore commented Jun 26, 2024

CPython's venv doesn't have a nushell activation script, so this is a virtualenv-only feature. But the activation scripts implemented in venv leave the CWD unchanged when deactivating, so I think it makes sense that the nushell script should work the same way.

@gaborbernat gaborbernat closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants