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

venv does not activate on my manjaro system for zsh #22899

Closed
karrtikr opened this issue Feb 12, 2024 · 27 comments
Closed

venv does not activate on my manjaro system for zsh #22899

karrtikr opened this issue Feb 12, 2024 · 27 comments
Assignees
Labels
experimenting Feature is part of an experiment triage-needed Needs assignment to the proper sub-team

Comments

@karrtikr
Copy link

          I just tested it again on my manjaro system and can confirm that the venv is not activated in zsh:
Systeminfo
Version: 1.86.1
Commit: 31c37ee8f63491495ac49e43b8544550fbae4533
Date: 2024-02-07T09:07:19.849Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Linux x64 6.6.10-1-MANJARO

In my last #22881 (comment), I've tested it successfully on windows+wsl with zsh.

Her are the logs of my manjaro system with the last fix from #22881 (comment):
Python.log

Originally posted by @matt-hires in #22881 (comment)

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 12, 2024
@karrtikr karrtikr added the experimenting Feature is part of an experiment label Feb 12, 2024
@karrtikr karrtikr self-assigned this Feb 12, 2024
@karrtikr
Copy link
Author

@matt-hires Based on your last comment #22881 (comment), do you mean to say that venv activation works for WSL + windows but not for your current system? If so, can you please provide screenshots on how you're determining whether the environment has activated?

@matt-hires
Copy link

That's correct. It's working on my Windows machine with wsl, but not on my manjaro linux system.

I checked if the venv was sourced with:

which pip

Which should show me the path to the pip in the venv directory, right?

@karrtikr
Copy link
Author

Actually that's not always true. Try using which python.

@matt-hires
Copy link

here is a gif how i checked it:

vscode

@karrtikr
Copy link
Author

Thanks, can you also provide the following #22900 (comment)? And lastly, the debug logs again please, make sure to use latest pre-release, thank you.

@matt-hires
Copy link

✅ Run 'Python: Clear cache and reload window' command

A screenshot when you hover over zsh:
image

Whether shell integration is actually working:
image

And lastly, the debug logs again please:
Python.log

@karrtikr
Copy link
Author

Thanks a lot for this, at this point we need some help from VS Code to reliably predict whether shell integration is working or not: microsoft/vscode#205058. It seems that even though the environment is set for your case:

2024-02-13 06:09:04.848 [debug] Prepending environment variable PATH in collection with /home/matthias/.vscode/extensions/ms-python.python-2024.1.10431006/pythonFiles/deactivate/zsh:/home/matthias/Development/src/cliargsparser/venv/bin:
2024-02-13 06:09:04.848 [debug] Setting environment variable VIRTUAL_ENV in collection to /home/matthias/Development/src/cliargsparser/venv
2024-02-13 06:09:04.849 [debug] Prepending environment variable PS1 in collection with (venv) 
2024-02-13 06:09:04.849 [debug] Setting environment variable VIRTUAL_ENV_PROMPT in collection to (venv) 

It's not reflected in the terminal. If you click "Show environment contributions" in the previous screenshot, it seems like the PATH variable there isn't being set correctly.

@karrtikr
Copy link
Author

I'm working on a temporary fix to remedy this: #22905, but it seems a long term solution has to come from VS Code at this point .

@matt-hires
Copy link

I guessed it might be something like this, due to the fact that the shell prompt correctly shows the venv python version.

And also thank you for your investigation into this.

@karrtikr
Copy link
Author

Of course. If you don't mind could you test out https://github.com/microsoft/vscode-python/actions/runs/7882029722/artifacts/1240529254 and see if it helps? You can use Extension: Install from VSIX to install the extension.

@karrtikr
Copy link
Author

Actually, that wouldn't help in your case. Never mind.

@karrtikr
Copy link
Author

Can you provide a screenshot of all variables that're supposed to be set in "Show environment contributions", and then check which those are set in terminal? For eg. You can run "echo $PATH" to see whether it's set.

@karrtikr
Copy link
Author

Please use the latest pre-release before providing this info.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 13, 2024
@karrtikr karrtikr added the info-needed Issue requires more information from poster label Feb 13, 2024
@norambna
Copy link

My system:

Version: 1.86.1
Commit: 31c37ee8f63491495ac49e43b8544550fbae4533
Date: 2024-02-07T09:07:19.849Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Linux x64 6.5.13-7-MANJARO

I just updated the Python extension to v2024.1.10441005 (pre-release). My log:
python.log

venv is not being activated in my zsh terminal. If I use bash, then it works fine.

@karrtikr
Copy link
Author

@norambna Can you run "echo $PATH" in your .zshrc shell and report the value you see there?

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 13, 2024
@karrtikr
Copy link
Author

I think you all might be running into: microsoft/vscode#205102.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Feb 13, 2024
@karrtikr karrtikr changed the title venv does not activate on my manjaro system venv does not activate on my manjaro system for zsh Feb 13, 2024
@matt-hires
Copy link

My contributed environment
# Terminal Environment Changes

## Extension: vscode.git

Enables the following features: git auth provider

- `GIT_ASKPASS=/opt/visual-studio-code/resources/app/extensions/git/dist/askpass.sh`
- `VSCODE_GIT_ASKPASS_NODE=/opt/visual-studio-code/code`
- `VSCODE_GIT_ASKPASS_EXTRA_ARGS=`
- `VSCODE_GIT_ASKPASS_MAIN=/opt/visual-studio-code/resources/app/extensions/git/dist/askpass-main.js`
- `VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-6e4ffbbc13.sock`

## Extension: ms-python.python

Activated environment for `./venv/bin/python`

- `PATH=/home/matthias/.vscode/extensions/ms-python.python-2024.1.10441459/pythonFiles/deactivate/zsh:/home/matthias/Development/src/cliargsparser/venv/bin:${env:PATH}`
- `VIRTUAL_ENV=/home/matthias/Development/src/cliargsparser/venv`
- `PS1=(venv) ${env:PS1}`
- `VIRTUAL_ENV_PROMPT=(venv) `
My $PATH env variable
echo $PATH
/home/matthias/.pyenv/shims:/home/matthias/.vscode/extensions/ms-python.python-2024.1.10441459/pythonFiles/deactivate/zsh:/home/matthias/Development/src/cliargsparser/venv/bin:/home/matthias/.local/share/gem/ruby/3.0.0/bin:/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/matthias/Development/android/sdk/tools:/home/matthias/Development/android/sdk/tools/bin:/home/matthias/Development/android/sdk/platform-tools:/home/matthias/Development/scripts/bin
And my $PATH variable after I sources venv manually by: source venv/bin/activate
echo $PATH
/home/matthias/Development/src/cliargsparser/venv/bin:/home/matthias/.pyenv/shims:/home/matthias/.vscode/extensions/ms-python.python-2024.1.10441459/pythonFiles/deactivate/zsh:/home/matthias/Development/src/cliargsparser/venv/bin:/home/matthias/.local/share/gem/ruby/3.0.0/bin:/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/matthias/Development/android/sdk/tools:/home/matthias/Development/android/sdk/tools/bin:/home/matthias/Development/android/sdk/platform-tools:/home/matthias/Development/scripts/bin

@karrtikr karrtikr removed the info-needed Issue requires more information from poster label Feb 13, 2024
@karrtikr
Copy link
Author

Can you also report the same when trying out the latest release version of the extension?

image

Appreciate all the help! @matt-hires

@karrtikr
Copy link
Author

Btw, can you share your .zshrc if possible?

@norambna
Copy link

@norambna Can you run "echo $PATH" in your .zshrc shell and report the value you see there?

I'm using the Python extension v2024.1.10441814 (pre-release) now and echo $PATH in my zsh terminal inside VSCode, where my venv is not being activated:

/home/luis/.pyenv/plugins/pyenv-virtualenv/shims:/home/luis/.pyenv/shims:/home/luis/.pyenv/bin:/home/luis/.vscode/extensions/ms-python.python-2024.1.10441814/pythonFiles/deactivate/zsh:/home/luis/Documents/genp/dj-genp/.venv/bin:/home/luis/.pyenv/bin:/home/luis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

And the PATH I'm getting in a bash terminal, where my venv is being activated automatically is:

/home/luis/.vscode/extensions/ms-python.python-2024.1.10441814/pythonFiles/deactivate/zsh:/home/luis/Documents/genp/dj-genp/.venv/bin:/home/luis/.pyenv/plugins/pyenv-virtualenv/shims:/home/luis/.pyenv/shims:/home/luis/.vscode/extensions/ms-python.python-2024.1.10441814/pythonFiles/deactivate/zsh:/home/luis/Documents/genp/dj-genp/.venv/bin:/home/luis/.pyenv/bin:/home/luis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

@matt-hires
Copy link

matt-hires commented Feb 13, 2024

here you go:
zshrc.zip

this includes .zshrc as well as an encapsulated .oh-my.zshrc which is sourced in the former one.

@karrtikr
Copy link
Author

Thanks. Can any of you provide the value of PATH asked here #22899 (comment) for the release version of the extension?

Btw, both your issues seem to be microsoft/vscode#205133. The above information would help confirm it.

@matt-hires
Copy link

When using Release Version v2024.0.1 of the extension:

Contributed Env:

# Terminal Environment Changes

## Extension: vscode.git

Enables the following features: git auth provider

- `GIT_ASKPASS=/opt/visual-studio-code/resources/app/extensions/git/dist/askpass.sh`
- `VSCODE_GIT_ASKPASS_NODE=/opt/visual-studio-code/code`
- `VSCODE_GIT_ASKPASS_EXTRA_ARGS=`
- `VSCODE_GIT_ASKPASS_MAIN=/opt/visual-studio-code/resources/app/extensions/git/dist/askpass-main.js`
- `VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-6e4ffbbc13.sock`

## Extension: ms-python.python

Activated environment for `./venv/bin/python`

- `PATH=/home/matthias/.vscode/extensions/ms-python.python-2024.0.1/pythonFiles/deactivate/zsh:/home/matthias/Development/src/cliargsparser/venv/bin:${env:PATH}`
- `VIRTUAL_ENV=/home/matthias/Development/src/cliargsparser/venv`
- `PS1=(venv) ${env:PS1}`
- `VIRTUAL_ENV_PROMPT=(venv) `

Path Variable:

echo $PATH
/home/matthias/.pyenv/shims:/home/matthias/.local/share/gem/ruby/3.0.0/bin:/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/matthias/Development/android/sdk/tools:/home/matthias/Development/android/sdk/tools/bin:/home/matthias/Development/android/sdk/platform-tools:/home/matthias/Development/scripts/bin

And the Path after sourcing venv manually source venv/bin/activate:

echo $PATH
/home/matthias/Development/src/cliargsparser/venv/bin:/home/matthias/.pyenv/shims:/home/matthias/.local/share/gem/ruby/3.0.0/bin:/home/matthias/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/matthias/Development/android/sdk/tools:/home/matthias/Development/android/sdk/tools/bin:/home/matthias/Development/android/sdk/platform-tools:/home/matthias/Development/scripts/bin

@norambna
Copy link

PATH in a zsh terminal when using Python Extension v2024.1.10451007 (pre-release):
/home/luis/.pyenv/plugins/pyenv-virtualenv/shims:/home/luis/.pyenv/shims:/home/luis/.pyenv/bin:/home/luis/.vscode/extensions/ms-python.python-2024.1.10451007/pythonFiles/deactivate/zsh:/home/luis/Documents/genp/dj-genp/.venv/bin:/home/luis/.pyenv/bin:/home/luis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

And PATH when using Python extension v2024.0.1:
/home/luis/.pyenv/plugins/pyenv-virtualenv/shims:/home/luis/.pyenv/shims:/home/luis/.pyenv/bin:/home/luis/.pyenv/bin:/home/luis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

@karrtikr
Copy link
Author

Ok great, thanks for confirming. It seems automatic shell integration for zsh shell isn't working for you, same as microsoft/vscode#205133. I encourage you to upvote that to raise awareness and priority.

As a workaround, try manual installation, which I expect should fix your issues: https://code.visualstudio.com/docs/terminal/shell-integration#_manual-installation.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
@norambna
Copy link

As a workaround, try manual installation, which I expect should fix your issues: https://code.visualstudio.com/docs/terminal/shell-integration#_manual-installation.

Yes, the "Manual installation" solved it on my system! Thanks and I also upvoted microsoft/vscode#205133

@matt-hires
Copy link

Workaround was also working for me, thx for your effort @karrtikr.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
experimenting Feature is part of an experiment triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants