2025, Oct 19 11:00
VS Code devcontainers: Pylance stuck on 'Loading information'? Fix it by setting workspaceFolder to /workspace
Pylance stuck on "Loading information" in VS Code devcontainers? Cause: workspace set to /. Fix fast: set workspaceFolder to /workspace in devcontainer.json.
VS Code devcontainers, Pylance stuck on “Loading information”, and the one-line fix
Autocomplete, go to definition, and hover info are baseline developer ergonomics. When they break inside a devcontainer, productivity plummets. A common symptom is Pylance permanently showing “Loading information”, frequent port switches, and RAM climbing until it drops sharply, repeating in a loop. Even a tiny Python file can trigger a persistent “Enumeration of workspace” message, while notebooks and scripts still execute just fine.
The good news: this behavior can come from a single misconfiguration. If the workspace is set to the container root, the language server ends up walking the entire filesystem instead of just your code folder.
Minimal failing setup
Even the smallest script may reproduce the issue:
label = 'test'
print(label)
A typical devcontainer that triggers endless indexing declares the workspace as the container root. Below is a representative configuration paired with docker-compose. Identifiers are illustrative, behavior identical.
{
  "name": "TorchDev",
  "dockerComposeFile": "./docker-compose.yaml",
  "service": "gpubox",
  "workspaceFolder": "/",
  "shutdownAction": "stopCompose",
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-toolsai.jupyter",
        "ms-python.vscode-pylance",
        "ms-python.python"
      ]
    }
  }
}
services:
  gpubox:
    container_name: gpubox
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8888:8888"
    environment:
      - JUPYTER_TOKEN=easy
    working_dir: /
    volumes:
      - ../:/workspace
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: ["gpu"]
              device_ids: ["0"]
    command: sleep infinity
What actually goes wrong
With the workspace set to /, the editor treats the entire container filesystem as the project. Pylance then attempts to enumerate that whole tree. The result is exactly what you see: never-ending “Loading information”, repeated “Enumeration of workspace”, and memory spikes followed by resets as the server restarts and tries again.
Restrict your workspace to just the folder you actually care about. Change your devcontainer.json so that VS Code’s workspace is /workspace (location of the code), not /.
The fix
Point the workspace to the mounted code directory rather than the container root. In this setup, the code lives in /workspace, so that path should be the workspace.
{
  "name": "TorchDev",
  "dockerComposeFile": "./docker-compose.yaml",
  "service": "gpubox",
  "workspaceFolder": "/workspace",
  "shutdownAction": "stopCompose",
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-toolsai.jupyter",
        "ms-python.vscode-pylance",
        "ms-python.python"
      ]
    }
  }
}
No other changes are required. This prevents the editor from crawling the entire container and confines the language server’s work to your project files.
Why this matters
Language features in Python, Jupyter, and Pylance depend on responsive indexing of your codebase. When the workspace includes the whole filesystem, even trivial projects degrade into heavy scans and restarts. Scoping the workspace correctly restores instant hover info, dependable autocomplete, and stable resource usage.
Practical takeaways
Keep the workspace narrow and explicit. Map your source into a dedicated directory inside the container and direct the editor to that path. If you notice “Enumeration of workspace” with a tiny project, verify that the workspace is not set to /. A precise workspace setting is often the only change needed to bring Pylance back to normal.
The article is based on a question from StackOverflow by I'mStuckOnLine911 and an answer by Philipp1297.