VS Code launch.json

cwd

Specifies the current working directory for the debugger, which is the base folder for any relative paths used in code. If omitted, defaults to ${workspaceFolder} (the folder open in VS Code).

As an example, say ${workspaceFolder} contains a py_code folder containing app.py, and a data folder containing salaries.csv. If you start the debugger on py_code/app.py, then the relative paths to the data file vary depending on the value of cwd:

cwd Relative path to data file
Omitted or ${workspaceFolder} data/salaries.csv
${workspaceFolder}/py_code ../data/salaries.csv
${workspaceFolder}/data salaries.csv

Here are some commonly used options:

  1. ${workspaceFolder}: This option sets the current working directory to the root folder of the current workspace in VS Code.
  2. ${fileDirname}: Sets the current working directory to the directory of the current active file