Skip to content

VS Code Terminal CWD Error Fix

Problem

The terminal process failed to launch: Starting directory (cwd) "/workspaces/loan-defenders" does not exist.

Root Cause

The .vscode/settings.json contained hardcoded Dev Container paths (/workspaces/loan-defenders) that don't exist when working locally on macOS, Windows, or Linux.

Solution

Use VS Code workspace variables instead of hardcoded paths for cross-platform compatibility.

Fixed Configuration

Before (Dev Container-specific):

{
    "python.defaultInterpreterPath": "/workspaces/loan-defenders/.venv/bin/python",
    "terminal.integrated.cwd": "/workspaces/loan-defenders"
}

After (Cross-platform):

{
    "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
    "terminal.integrated.cwd": "${workspaceFolder}"
}

How It Works

  • ${workspaceFolder} - VS Code built-in variable that resolves to:
  • /Users/niksac/github/loan-defenders (macOS local)
  • /workspaces/loan-defenders (Dev Container)
  • C:\Users\username\github\loan-defenders (Windows local)
  • /home/username/github/loan-defenders (Linux local)

Files Updated

  1. .vscode/settings.json - Changed to use ${workspaceFolder} variable
  2. .devcontainer/post-create.sh - Updated to generate cross-platform settings
  3. apps/api/pyproject.toml - Removed hardcoded coverage path

Verification

  1. Reload VS Code: Cmd+Shift+P → "Developer: Reload Window"
  2. Open new terminal: Should open in workspace root without errors
  3. Test in Dev Container: Settings work in both local and containerized environments

Prevention

  • Never use absolute paths in .vscode/settings.json
  • Always use VS Code variables: ${workspaceFolder}, ${workspaceFolderBasename}, etc.
  • Test locally before committing Dev Container configurations

Fixed: October 18, 2025
Impact: Local development on macOS, Windows, Linux, and Dev Containers