Skip to content

Deactivate Script in remote server is Permission denied #23195

Closed

Description

@Randark-JMT

Type: Bug

When creating a virtual environment with python3 -m venv env and then opening the terminal

((env) ) randark@developer:~/code/20240407-ssti$ 

Anomalous double-bracket-wrapped environment hints appear

At the same time, when trying to de-activate the virtual environment, an anomalous insufficient permissions message appears

((env) ) randark@developer:~/code/20240407-ssti$ deactivate
bash: /home/randark/.vscode-server/extensions/ms-python.python-2024.4.0/python_files/deactivate/bash/deactivate: Permission denied

Extension version: 2024.4.0
VS Code version: Code 1.87.2 (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:20:17.278Z)
OS version: Windows_NT x64 10.0.22631
Modes: Unsupported
Remote OS version: Linux x64 6.5.0-17-generic

System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i7-13620H (16 x 2918)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.69GB (34.22GB free)
Process Argv --crash-reporter-id c9f4871d-20e2-430d-8db2-04870357e670
Screen Reader no
VM 29%
Item Value
Remote SSH: Developer
OS Linux x64 6.5.0-17-generic
CPUs 13th Gen Intel(R) Core(TM) i7-13620H (4 x 2918)
Memory (System) 7.71GB (5.26GB free)
VM 29%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp2r3:30993541
dsvsc020:30976470
pythonait:31006305
gee8j676:31009558
dsvsc021:30996838
g1icg217:30999571

Activity

  1. VitusAcabado commented on Apr 8, 2024

    @VitusAcabado

    Experiencing the same issue as well. This was after the new update.

    Am running on WSL2 Ubuntu 20.04

  2. ykursav commented on Apr 8, 2024

    @ykursav

    For work around -> With root access you can give rights to deactivate file with chmod.
    sudo chmod 777 .vscode-server/extensions/ms-python.python-2024.4.0/python_files/deactivate/bash/deactivate

  3. mschoettner commented on Apr 8, 2024

    @mschoettner

    Same problem here, which also persists when rolling back to the previous version of VSCode (1.87.2). Cannot use the workaround that was suggested as I don't have sudo rights on the remote server.

  4. mschoettner commented on Apr 8, 2024

    @mschoettner

    Update: After also deleting .vscode-server on the remote to force a reinstall of VS Code Server, it now seems to work again with version 1.87.2. So it probably is the last update causing the issue.

  5. Burhan-Q commented on Apr 8, 2024

    @Burhan-Q

    +1

    Pop!_OS 22.04 LTS
    VSCode 1.88.0 Commit: 5c3e652f63e798a5ac2f31ffd0d863669328dc4c

    Found this comment recommending to downgrade the Python Extension from 2024.4.0 to 2024.2.1 which after a VSCode refresh and restarting the terminal, resolved the issue for me.

  6. leongj commented on Apr 8, 2024

    @leongj

    +1

    Pop!_OS 22.04 LTS VSCode 1.88.0 Commit: 5c3e652f63e798a5ac2f31ffd0d863669328dc4c

    Found this comment recommending to downgrade the Python Extension from 2024.4.0 to 2024.2.1 which after a VSCode refresh and restarting the terminal, resolved the issue for me.

    This worked for me on VSCode Insiders v1.89.0-insider

  7. anthonykim1 commented on Apr 10, 2024

    @anthonykim1

    Hello everyone the double parenthesis is fixed and tracked via: #23193. I'll look more into deactivate with remote scenarios.

  8. eitanturok commented on Apr 10, 2024

    @eitanturok

    I'm running into the same issue on my MAC. Here are the specific details of my VSCode setup:

    Version: 1.87.1 (Universal)
    Commit: 1e790d77f81672c49be070e04474901747115651
    Date: 2024-03-06T00:23:16.418Z (1 mo ago)
    Electron: 27.3.2
    ElectronBuildId: 26836302
    Chromium: 118.0.5993.159
    Node.js: 18.17.1
    V8: 11.8.172.18-electron.0
    OS: Darwin arm64 23.3.0
    

    Update: Following Yunus Kursav (@ykursav)'s answer, I ran a slightly modified command

    sudo chmod 777 /root/.vscode-server/extensions/ms-python.python-2024.4.0/python_files/deactivate/bash/deactivate
    deactivate

    and now everything works!

  9. elenavolkova93 commented on Apr 15, 2024

    @elenavolkova93

    +1

  10. funkindy commented on Apr 17, 2024

    @funkindy

    On local venvs deactivate also doesnt work and gives zsh: permission denied.

    Fix is the same: sudo chmod +x ~/.vscode/extensions/ms-python.python-2024.4.1/python_files/deactivate/zsh/deactivate

    I am on mac M1pro with zsh.

  11. matt-forallepsilon commented on Apr 18, 2024

    @matt-forallepsilon

    +1

  12. juhlinm commented on Apr 18, 2024

    @juhlinm

    +1

  13. tljstewart commented on Apr 22, 2024

    @tljstewart

    ✅ chmod +x ~/.vscode/extensions/ms-python.python-2024.4.1/python_files/deactivate/zsh/deactivate
    ❌ chmod 777

  14. 1 remaining item

  15. nicola-lunghi commented on Apr 24, 2024

    @nicola-lunghi

    the issue is that the deactivate script is created with the wrong permission in the

    ~/.vscode/extensions/ms-python.python-2024.4.1/python_files/deactivate/bash/deactivate

  16. estelabalboa commented on Apr 29, 2024

    @estelabalboa

    +1

  17. anthonykim1 commented on Apr 30, 2024

    @anthonykim1

    Deactivation with the current terminal environment variable activation experiment has some limitation as previously mentioned in: #22037. We then have made effort to inserting deactivate script path from Python extension to user to work around this, but I can see the permission issue for remote scenarios.

    This is bit tricky since we cannot really automatically run deactivation with user admin permission without admin password, which should be private and is not ideal for extension to attempt. I'll be looking around to see if there are alternative ways we can go about injecting deactivation path for remote scenarios.

    For now see, lets see if following https://github.com/microsoft/vscode-python/wiki/Fixing-%22deactivate%22-command-for-Virtual-Environments and inserting the path to deactivate script yourself(user) in shell specific initialization script works.

  18. taralx commented on May 1, 2024

    @taralx

    Why is this script even here? I have this in my .bashrc now:

    if [[ -n $VIRTUAL_ENV ]]; then
        unset VSCODE_ENV_PREPEND VSCODE_ENV_REPLACE
        source "$VIRTUAL_ENV/bin/activate"
    fi
    
  19. bigalnz commented on May 23, 2024

    @bigalnz

    What if I am running VSCode on Windows and want to connect (SSH) to Linux - what is the command to fix in this case?

  20. covracer commented on Jun 14, 2024

    @covracer

    https://github.com/microsoft/vscode-python/blob/main/python_files/deactivate/bash/deactivate does not currently have any executable bits set. It looks like it used to but #22921 removed them. I've proposed #23620 to restore them.

    I've noticed that pyenv-virtualenv requires source deactivate rather than deactivate https://github.com/pyenv/pyenv-virtualenv/blob/37917069ecba16602decd3dd2c8b09121c673a41/shims/deactivate#L5

    If there's a reason to prefer it, I think it'd be acceptable for vscode-python to also require the source deactivate syntax. I think the sourcing approach would need additional changes like switching from $0 to $BASH_SOURCE https://stackoverflow.com/a/35006505/3787516.

  21. jamesylgan commented on Jun 21, 2024

    @jamesylgan

    source deactivate doesn't seem to work either - but v24.2.1 does solve the issue

  22. karthiknadig commented on Jun 21, 2024

    @karthiknadig
    Member

    James Gan (@jamesylgan) Try the pre-release it should have the fix

  23. locked as resolved and limited conversation to collaborators on Jul 22, 2024
  24. anthonykim1 commented on Jun 12, 2025

    @anthonykim1

    We are planning to deprecate terminal environment experiment in favor of shell activation coming from python environment extension.

    Could people try out the Python environment extension(https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs) with
    python-envs.terminal.autoActivationType set to shell startup?

    This is supposed to be the "better"/"proper" activation without showing the source... activate on your terminal.

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

Metadata

Metadata

Labels

info-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions