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

Deactivate Script in remote server is Permission denied #23195

Closed
Randark-JMT opened this issue Apr 7, 2024 · 22 comments · Fixed by #23620
Closed

Deactivate Script in remote server is Permission denied #23195

Randark-JMT opened this issue Apr 7, 2024 · 22 comments · Fixed by #23620
Assignees
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@Randark-JMT
Copy link

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

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 7, 2024
@VitusAcabado
Copy link

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

Am running on WSL2 Ubuntu 20.04

@ykursav
Copy link

ykursav commented Apr 8, 2024

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

@mschoettner
Copy link

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.

@mschoettner
Copy link

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.

@Burhan-Q
Copy link

Burhan-Q commented Apr 8, 2024

+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.

@leongj
Copy link

leongj commented Apr 8, 2024

+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

@anthonykim1
Copy link

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

@eitanturok
Copy link

eitanturok commented Apr 10, 2024

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 @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!

@elenavolkova93
Copy link

+1

@funkindy
Copy link

funkindy commented Apr 17, 2024

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.

@matt-forallepsilon
Copy link

+1

1 similar comment
@juhlinm
Copy link

juhlinm commented Apr 18, 2024

+1

@tljstewart
Copy link

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

@seanmavley
Copy link

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

This worked for me on WSL2 Ubuntu. Thanks

@nicola-lunghi
Copy link

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

@estelabalboa
Copy link

+1

@anthonykim1
Copy link

anthonykim1 commented Apr 30, 2024

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.

@taralx
Copy link

taralx commented May 1, 2024

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

@bigalnz
Copy link

bigalnz commented May 23, 2024

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

@covracer
Copy link

covracer commented Jun 14, 2024

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.

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
@jamesylgan
Copy link

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

@karthiknadig
Copy link
Member

@jamesylgan Try the pre-release it should have the fix

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jun 21, 2024
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 Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

Successfully merging a pull request may close this issue.