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

Cannot deactivate venv in terminal while venv/bin/python is interpreter #23449

Closed
k98kurz opened this issue May 18, 2024 · 7 comments · Fixed by #23620
Closed

Cannot deactivate venv in terminal while venv/bin/python is interpreter #23449

k98kurz opened this issue May 18, 2024 · 7 comments · Fixed by #23620
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@k98kurz
Copy link

k98kurz commented May 18, 2024

Type: Bug

  1. Run the bash command python -m venv venv in the root directory.
  2. Run the "select python interpreter" command in VSCode and select "./venv/bin/python".
  3. Close all existing terminals in VSCode with the trash icon.
  4. Create a new terminal in VSCode.
  5. which python will show the local venv/bin/python path.
  6. deactivate results in an error "/home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate: Permission denied"

Being able to deactivate the venv is a necessary feature for development.

Extension version: 2024.6.0
VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:16:23.416Z)
OS version: Linux x64 6.5.0-35-generic snap
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2900)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Load (avg) 6, 4, 4
Memory (System) 31.20GB (26.26GB free)
Process Argv --no-sandbox --force-user-env --crash-reporter-id 8288fe70-1d22-4ecb-a399-2ca5eb4778fd
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu-xorg
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu-xorg
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
tftest:31042121
vstes516:30244333
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelc:31048052
dsvsc021:30996838
jg8ic977:31013176
pythoncenvpt:31049070
fchga941:31046352
dvdeprecation:31052039
pythonprc:31047982
dwnewjupytercf:31046870
26j00206:31048877

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label May 18, 2024
@HappyCoder77
Copy link

I have the same problem It almost make crazy.

@s-kai273
Copy link

although deactivate command should work, I'm wondering what the proper behavior is...
when opening a new terminal, python default path should be global one?

@hnur-eris
Copy link

I had same issue. First of all you need to delete virtual environment (./venv directory) on your path, and then try deactivate command once again.

@ilmari99
Copy link

I don't know the underlying reason for the bug, but changing the permissions of the deactivate script worked for me: chmod u+x /home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate.

@michelmetran
Copy link

I don't know the underlying reason for the bug, but changing the permissions of the deactivate script worked for me: chmod u+x /home/username/.vscode/extensions/ms-python.python-2024.6.0/python_files/deactivate/bash/deactivate.

I thank!
Here I was having the same problem and by changing the permissions I managed to solve it!

@anthonykim1
Copy link

anthonykim1 commented May 29, 2024

In a remote scenario there is the permission issue: #23195

@k98kurz Can you try with the enhanced permission referenced in #23195?

Another way would be opting out of terminal env activation by adding:
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"],
in your settings.json

@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 29, 2024
@k98kurz
Copy link
Author

k98kurz commented May 30, 2024

I can confirm that the permissions solution works

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label May 30, 2024
karthiknadig pushed a commit that referenced this issue Jun 17, 2024
#22921 removed executable bits:
```diff
diff --git a/pythonFiles/deactivate/bash/deactivate b/python_files/deactivate/bash/deactivate
old mode 100755
new mode 100644
similarity index 100%
rename from pythonFiles/deactivate/bash/deactivate
rename to python_files/deactivate/bash/deactivate
```


https://github.com/microsoft/vscode-python/pull/22921/files#diff-796809259ce3b33f54a33371e898048faf2f7f912cd1bbe11059feb40a63a58d

Set them back.


Fixes #23449 and #23195
DonJayamanne pushed a commit that referenced this issue Jun 24, 2024
#22921 removed executable bits:
```diff
diff --git a/pythonFiles/deactivate/bash/deactivate b/python_files/deactivate/bash/deactivate
old mode 100755
new mode 100644
similarity index 100%
rename from pythonFiles/deactivate/bash/deactivate
rename to python_files/deactivate/bash/deactivate
```


https://github.com/microsoft/vscode-python/pull/22921/files#diff-796809259ce3b33f54a33371e898048faf2f7f912cd1bbe11059feb40a63a58d

Set them back.


Fixes #23449 and #23195
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Jun 28, 2024
microsoft#22921 removed executable bits:
```diff
diff --git a/pythonFiles/deactivate/bash/deactivate b/python_files/deactivate/bash/deactivate
old mode 100755
new mode 100644
similarity index 100%
rename from pythonFiles/deactivate/bash/deactivate
rename to python_files/deactivate/bash/deactivate
```


https://github.com/microsoft/vscode-python/pull/22921/files#diff-796809259ce3b33f54a33371e898048faf2f7f912cd1bbe11059feb40a63a58d

Set them back.


Fixes microsoft#23449 and microsoft#23195
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants