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

"Run Python File" fails when using Git Bash + Conda #22434

Closed
adamerose opened this issue Nov 7, 2023 · 3 comments
Closed

"Run Python File" fails when using Git Bash + Conda #22434

adamerose opened this issue Nov 7, 2023 · 3 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@adamerose
Copy link

Type: Bug

Clicking the Run Python File button in a Conda environment with Git Bash fails, because it uses backslashes in the environment path which Git Bash treats as escape characters. Solution is to use forward slashes or wrap the path in quotes.

Steps to reproduce:

  1. Use Git Bash as the default shell for VS Code's integrated terminal
  2. Open a project and create a Conda environment in the project root (conda create -p "./cenv")
  3. Select the Conda environment as the workspace interpreter (F1 -> Python: Select Interpreter)
  4. Click the Run Python File button in the top right
  5. It tries running conda activate C:\path\to\cenv and fails
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ source activate
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ conda activate C:\_MyFiles\Programming\Sandbox\clip\cenv

EnvironmentNameNotFound: Could not find conda environment: C:_MyFilesProgrammingSandboxclipcenv
You can list all discoverable environments with `conda info --envs`.


(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ cd c:/_MyFiles/Programming/Sandbox/example
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ C:/_MyFiles/Programming/Sandbox/clip/cenv/python.exe c:/_MyFiles/Programming/Sandbox/example/main.py
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$

image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.18
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

terminal
• executeInFileDir: "<placeholder>"

Extension version: 2023.20.0
VS Code version: Code 1.84.0 (d037ac076cee195194f93ce6fe2bdfe2969cc82d, 2023-11-01T11:29:04.398Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 5800X 8-Core Processor (16 x 3793)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.90GB (32.24GB free)
Process Argv --crash-reporter-id 1da03074-efe6-46e2-b136-4c0275639a49
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30880072
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
a9j8j154:30646983
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30882110
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30871694
pythonregdiag2cf:30871583
pyreplss1:30879912
pythonmypyd1:30879173
pythoncet00cf:30874137
pythontbext0:30879054
dsvsc017cf:30880893
dsvsc018:30880894
aa_t_chat:30882232

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 7, 2023
@karrtikr
Copy link

karrtikr commented Nov 7, 2023

@adamerose , Python extension does not support Git bash currently, and such an issue was recently closed because of lack of community interest: #15799 as well as significant technical blockers which can only be resolved by VS Code: #15799 (comment).

Hence closing this.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
@adamerose
Copy link
Author

@karrtikr

Clicking Run Python File seems to work fine with Git Bash + venv:

image

It just behaves differently for conda. Can't the extension use forward slashes for conda like it does for venv? The upstream issue you linked is about an Extension API for escaping backslashes but I don't think that is the only solution

@karrtikr
Copy link

karrtikr commented Nov 7, 2023

While it's true that using forward slashes might be a suitable workaround for conda, it might not. Supporting git bash results in other complications hence we cannot simply officially support it at this point.

That being said, if you can contribute a fix and demonstrate to us that it works, we'll be happy to accept it.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2023
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

No branches or pull requests

2 participants