Skip to content

Fix duplicated venv prompt parenthesis - #23201

Merged
Anthony Kim (anthonykim1) merged 1 commit into
microsoft:mainfrom
anthonykim1:fix-dupVenv
Apr 8, 2024
Merged

Anthony Kim (anthonykim1) merged 1 commit into
microsoft:mainfrom
anthonykim1:fix-dupVenv

Conversation

@anthonykim1

@anthonykim1 Anthony Kim (anthonykim1) commented Apr 8, 2024 •

Copy link
Copy Markdown

Resolves: #23193 #23184

Resolve duplicated (.venv) prompt for users terminal.
Issue came from: #23080

@anthonykim1 Anthony Kim (anthonykim1) added area-terminal bug Issue identified by VS Code Team member as probable bug labels Apr 8, 2024
@anthonykim1
Anthony Kim (anthonykim1) marked this pull request as ready for review April 8, 2024 17:38
@anthonykim1 Anthony Kim (anthonykim1) added the skip tests Updates to tests unnecessary label Apr 8, 2024
@anthonykim1
Anthony Kim (anthonykim1) merged commit eed0c3b into microsoft:main Apr 8, 2024
@karthiknadig Karthik Nadig (karthiknadig) changed the title Fix duplicated venv prompt Fix duplicated venv prompt parenthesis Apr 8, 2024
Anthony Kim (anthonykim1) added a commit to anthonykim1/vscode-python that referenced this pull request Apr 9, 2024
Resolves: microsoft#23193 microsoft#23184

Resolve duplicated (.venv) prompt for users terminal.
Issue came from: microsoft#23080
Wes McKinney (wesm) pushed a commit to posit-dev/positron that referenced this pull request May 10, 2024
Wasim Lorgat (seeM) pushed a commit to posit-dev/positron that referenced this pull request May 12, 2024
Wes McKinney (wesm) pushed a commit to posit-dev/positron that referenced this pull request May 13, 2024
@AddisonG

Addison G (AddisonG) commented Sep 8, 2024 •

Copy link
Copy Markdown

Not sure if I'm just unlucky, but my Mac setup with work, and Ubuntu setup at home, for 2 different projects, are both missing the parenthesis now. So I now get:

venvaddison:~/tmp

Instead of:

(venv) addison:~/tmp

I have no idea if this is related to this issue, but it sure looks like it is.

Python3.13, vscode: 1.93.0, Microsoft Python Extension: v2024.14.0


EDIT:

Ahh yes, I see. VIRTUAL_ENV_PROMPT (within the venv/bin/activate script) is no longer set to include parenthesis in new python versions. But nobody seems to realise that, as they're using old versions of python. I might be the first to realise, since I cannot for the life of me find anything on the internet about this.

This appears to be stemming from a lack of communication or understanding between those 2 projects. Or perhaps I'm extremely misguided, and rambling like a fool.

To fix this, you can add this to your settings JSON:

"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],

And then do a hard reload of vscode.

See also my SO post

@Chrisguagliano

Copy link
Copy Markdown
Member

Addison G (@AddisonG) THANK YOU! This has been bugging me for months and never looked into it.

@Chrisguagliano

Chris Guagliano (Chrisguagliano) commented Sep 11, 2024 •

Copy link
Copy Markdown
Member

Daniel Imms (@Tyriar) the issue that Addison and myself are experiencing might be VSCode related. If I make the update that Addison mentioned, VSCode terminal correctly shows (.venv) but a standard terminal shows double parentheses ((.venv) ) . I am on Ubuntu 22.04, Python 3.10.12, VSCode 1.93.0.

The issue persists on WSL, as well.

@AddisonG

Addison G (AddisonG) commented Sep 11, 2024 •

Copy link
Copy Markdown

You're right. I actually didn't check the fix in a normal terminal. It's not related to that file, but that's a hack to fix it.

Good to know someone else is having this issue, not just me. We can suffer together!

I made a ticket, since now I know I'm not going crazy:
#24097

I'm now pretty confident that this is a Vscode problem - not venv.

@akprodromou

Copy link
Copy Markdown

check the venv’s activation script:

nano venv/bin/activate

Look at this section of your activate script:

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1:-}"
    PS1="("'(venv) '") ${PS1:-}"
    export PS1
fi

Replace the problematic lines with:

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
    _OLD_VIRTUAL_PS1="${PS1:-}"
    PS1="(venv) ${PS1:-}"
    export PS1
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-terminal bug Issue identified by VS Code Team member as probable bug skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double parantheses: "((.venv) )"

5 participants