pydev debugger: unable to find translation for: (please revise your path mappings)

795 Views Asked by At

I have a problem using debugpy with vscode on Windows with the repository on a local server. I have a dockerized django app with the following dockerfile and docker-compose:

FROM python:3.6.15-slim-bullseye

ARG ENVIRONMENT=master

# Python logs to STDOUT
ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    TZ=America/Santiago \
    DEBIAN_FRONTEND=noninteractive

WORKDIR /app

COPY requirements.txt .

RUN set -x \
    && buildDeps=" \
    git \
    build-essential \
    libpq-dev \
    libssl-dev \
    locales \
    gnupg \
    wget \
    " \
    && runDeps=" \
    pkg-config \
    unzip \
    lsb-release \
    libcairo2-dev \
    libpangocairo-1.0-0 \
    " \
    && apt-get update \
    && apt-get install curl tzdata -y \
    && apt-get install -y --no-install-recommends $buildDeps $runDeps \
    && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
    && dpkg-reconfigure -f noninteractive tzdata \
    && locale-gen es_CL.UTF-8 \
    && sed -i -e 's/# es_CL.UTF-8 UTF-8/es_CL.UTF-8 UTF-8/' /etc/locale.gen \
    && wget http://dev.mysql.com/get/mysql-apt-config_0.8.26-1_all.deb \
    && echo 'mysql-apt-config mysql-apt-config/select-product select Ok' | debconf-set-selections \
    && dpkg -i mysql-apt-config_0.8.26-1_all.deb \
    && rm mysql-apt-config_0.8.26-1_all.deb \
    && apt-get update \
    && apt-get install -y libmysqlclient-dev \
    && pip install -r requirements.txt --no-dependencies \
    && apt-get clean \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/* \
    && rm -Rf /tmp/*

version: "3.8"

services:
  django:
    image: "django:dev"
    build:
      context: .
      dockerfile: ./Dockerfile
      args:
        - ENVIRONMENT=local
    command: sh -c "python manage.py runserver 0.0.0.0:8000"
    container_name: django
    restart: "no"
    env_file:
      - .env
    volumes:
      - ".:/app:rw"
    ports:
      - "8000:8000"
      - "9000:9000"
      - "6000:6000"
    networks:
      dev-net:

I'm using the folowing launch.json in vscode:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Django debug",
      "type": "python",
      "request": "attach",
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "/app"
        }
      ],
      "port": 6000,
      "host": "192.168.100.20"
    }
  ]
}

The debugger connects, but when a I try to set a breakpoint, it throws pydev debugger: unable to find translation for <file> (please revise your path mappings) The remote repository is mounted as a drive in Windows, so that shouldn't be an issue. The thing is that using the exact same config in Mac OS, it works perfectly, so I'm pretty sure it's a Windows problem. Any suggestions?

Thanks!

EDIT: I tried using a Ubuntu VM under Windows and it also worked without issue. Definitely a Windows problem.

1

There are 1 best solutions below

0
NICOLÁS ANTONIO PINO LEVA On

So, I found the solution. The reason it fails is because of path translation differences between Windows and Unix (\ vs /). Since the application runs in a Linux Docker container, it fails to translate the path correctly when trying to locate the requested file for the desired breakpoint: enter image description here

VSCode offers a solution for this issue called Remote Window. Using it, I was able to debug a Unix application from Windows without any problems. Hope this helps!