The ms-python.python plug-in in the vscode remote environment has the wrong PATH path order in the remote Linux #22724
Labels
experimenting
Feature is part of an experiment
info-needed
Issue requires more information from poster
triage-needed
Needs assignment to the proper sub-team
Remote-SSH Log
``` (base)[dev@localhost web_vpn]$ conda activate flask_web (flask_web)[dev@localhost web_vpn]$ echo$PATH
/home/dev/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/usr/local/cuda-12.1/bin:/usr/lib/jvm/jdk-17.0.8/bin:/bin:/home/dev/miniconda3/envs/flask_web/bin:/home/dev/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dev/.local/bin:/home/dev/bin:/home/dev/miniconda3/bin:/home/dev/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/bin/remote-cli:/usr/local/cuda-12.1/bin:/usr/lib/jvm/jdk-17.0.8/bin:/bin:/home/dev/miniconda3/bin:/home/dev/miniconda3/condabin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dev/.local/bin:/home/dev/bin
(flask_web)[dev@localhost web_vpn]$
```
Thank you for taking time out of your busy schedule to read my issue.
I'm using the python plugin (it's plugin id is: ms-python.python), above is the vscode remote startup, I switch conda to the virtual environment "flask_web", you can see that "(flask_web)" is already in front of it. However, when I use echo $PATH to check the environment variable, "/bin" is in front of "/home/dev/miniconda3/envs/flask_web/bin" in the conda virtual environment directory. " in front of it.
However, when I connect to the server using xshell's ssh and start the "flask_web" virtual environment, the first $PATH is the bin directory of the conda virtual environment.
I've tried a lot of things on the internet, such as changing the remote server setting:
None of these apply, it is still /bin that takes precedence over the bin directory of the conda virtual environment in the vscode remote's $PATH. This also results in me using python commands in vscode remote's shell, launching an older version of python in /bin, and not being able to use the python virtual environment that I really need.
But the good thing is, when running the python program using ctrl+F5 at that time, it runs the command:
(base)[dev@localhost web_vpn]$ /usr/bin/env /home/dev/miniconda3/envs/flask_web/bin/python /home/dev/.vscode-server/extensions/ms- python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/... /... /debugpy/launcher 58218 -- /home/dev/dev/web_vpn/test.py
Starts python in the conda virtual environment directory directly with parameters (this is not affected by the $PATH variable, since python in the virtual environment is started via an absolute path). So the conda virtual environment is used correctly when python is running.
The following is from the environment contribution of the vscode terminal, you can see that the ms-python.python plugin seems to set the $PATH variable backwards in the remote environment, advancing the root directory to "/bin", but this only happens in the remote case, in the local one. Running the code locally does not cause this problem.

Thank you very much!
The text was updated successfully, but these errors were encountered: