microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.18k stars 508 forks source link

Fail to debug a python project #4209

Open v-ruizh opened 5 months ago

v-ruizh commented 5 months ago

OS: Win 10 Build Version: 20240117.1

Repro Steps:

  1. Open a python project myapp.zip in VS Code Insiders.
  2. F1 -> Docker: Add Docker Files to Workspace -> Python: General -> Include docker compose files.
  3. Debug this project.
  4. Check whether succeeds to debug the python project or not.

Expect: Succeed to debug the python project.

Actual: Fail to debug the python project with an error. image

More Info:

  1. This issue also reproduces for Django or Flask project.
  2. This is the launch.json file. image
bwateratmsft commented 5 months ago

I am not able to reproduce on a Win11 machine. @v-ruizh does this happen consistently on more than one machine?

bwateratmsft commented 5 months ago

I was able to reproduce in VSCode Insiders. I'll investigate and see what I can figure out.

v-ruizh commented 5 months ago

Verified this issue on Docker extension 20240202.4, it does not reproduce on Windows platform. But it still reproduces on Mac and Linux platforms.

bwateratmsft commented 4 months ago

I've found that what's happening is the Python extension is validating that the Python executable is valid, but the Python command we are giving is the one to launch in the container, however they're validating against the host. I don't know why this is only happening in Insiders.

I've noticed that on my system at least, python refers to Python 3, and python3 results in a Windows Store page opening up, so if our debug configuration resolves python3 it fails.

However, in my WSL instance, python does not work by default, and python3 is the only valid command.

This is a problem--this forces the user to have python locally and inside the container and on the PATH environment variable, which is not helpful.

bwateratmsft commented 4 months ago

@v-ruizh Can you share the results from the following commands on Windows, Mac, and Linux?

python python3

On my Windows device, python launches the Python interpreter, but python3 opens a Windows Store page.

In my Linux WSL instance and on my Macbook, python is not found and python3 launches the Python interpreter.

v-ruizh commented 4 months ago

@bwateratmsft We have the same results.

On my Windows device, python launches the Python interpreter, but python3 opens a Windows Store page. image

On my Mac and Ubuntu22.04, python is not found and python3 launches the Python interpreter. image

bwateratmsft commented 4 months ago

Blocked on https://github.com/microsoft/vscode-python/issues/22884