Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Iterative Dvc DVC Environment Variables

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Configuration
Last Updated 2026-02-10 10:00 GMT

Overview

22 environment variables that control DVC behavior including directory paths, Studio integration, experiment configuration, and debugging options.

Description

DVC defines a set of environment variables in `dvc/env.py` that allow runtime configuration without modifying config files. These variables control directory overrides, Studio authentication, experiment metadata, analytics, daemon operation, and debugging. They are used across the codebase via `os.environ.get()` and `os.getenv()` calls.

Usage

Use these environment variables when you need to override DVC defaults in CI/CD pipelines, Docker containers, or custom deployment scripts. They are particularly important for DVC Studio integration, experiment execution, and headless/daemon operations.

System Requirements

Category Requirement Notes
OS Any Environment variables work on all platforms
Python >= 3.9 Same as core DVC

Dependencies

No additional dependencies beyond core DVC.

Credentials

The following environment variables contain sensitive authentication data:

  • `DVC_STUDIO_TOKEN`: Authentication token for DVC Studio API access. Never commit this value.
  • `STUDIO_TOKEN`: Alternative/fallback token variable for Studio authentication.

Quick Install

# Set Studio authentication
export DVC_STUDIO_TOKEN="your-studio-token-here"
export DVC_STUDIO_URL="https://studio.iterative.ai"

# Override config directories
export DVC_GLOBAL_CONFIG_DIR="/custom/path/to/config"
export DVC_SITE_CACHE_DIR="/custom/cache/path"

# Enable debugging
export DVC_SHOW_TRACEBACK=1

# Disable analytics
export DVC_NO_ANALYTICS=1

# Configure experiment behavior
export DVC_EXP_GIT_REMOTE="origin"
export DVC_EXP_AUTO_PUSH=1

Code Evidence

All 22 environment variable constants from `dvc/env.py:1-22`:

DVC_ANALYTICS_ENDPOINT = "DVC_ANALYTICS_ENDPOINT"
DVC_DAEMON = "DVC_DAEMON"
DVC_DAEMON_LOGFILE = "DVC_DAEMON_LOGFILE"
DVC_EXP_AUTO_PUSH = "DVC_EXP_AUTO_PUSH"
DVC_EXP_BASELINE_REV = "DVC_EXP_BASELINE_REV"
DVC_EXP_GIT_REMOTE = "DVC_EXP_GIT_REMOTE"
DVC_EXP_NAME = "DVC_EXP_NAME"
DVC_GLOBAL_CONFIG_DIR = "DVC_GLOBAL_CONFIG_DIR"
DVC_IGNORE_ISATTY = "DVC_IGNORE_ISATTY"
DVC_NO_ANALYTICS = "DVC_NO_ANALYTICS"
DVC_PAGER = "DVC_PAGER"
DVC_ROOT = "DVC_ROOT"
DVC_SHOW_TRACEBACK = "DVC_SHOW_TRACEBACK"
DVC_SITE_CACHE_DIR = "DVC_SITE_CACHE_DIR"
DVC_STUDIO_OFFLINE = "DVC_STUDIO_OFFLINE"
DVC_STUDIO_REPO_URL = "DVC_STUDIO_REPO_URL"
DVC_STUDIO_TOKEN = "DVC_STUDIO_TOKEN"  # noqa: S105
DVC_STUDIO_URL = "DVC_STUDIO_URL"
DVC_SQLALCHEMY_ECHO = "DVC_SQLALCHEMY_ECHO"
DVC_SYSTEM_CONFIG_DIR = "DVC_SYSTEM_CONFIG_DIR"
DVC_UPDATER_ENDPOINT = "DVC_UPDATER_ENDPOINT"
DVC_STAGE = "DVC_STAGE"

Stage execution environment setup from `dvc/stage/run.py:78-89`:

def prepare_kwargs(stage, run_env=None):
    from dvc.env import DVC_ROOT, DVC_STAGE

    kwargs = {"cwd": stage.wdir, "env": fix_env(None), "close_fds": True}
    if run_env:
        kwargs["env"].update(run_env)
    if DVC_ROOT not in kwargs["env"]:
        kwargs["env"][DVC_ROOT] = stage.repo.root_dir

    # Create DVC_STAGE env variable for every command
    kwargs["env"][DVC_STAGE] = stage.addressing

Directory override from `dvc/dirs.py:12-21`:

def system_config_dir():
    return os.getenv(env.DVC_SYSTEM_CONFIG_DIR) or platformdirs.site_config_dir(
        APPNAME, APPAUTHOR
    )

def global_config_dir():
    return os.getenv(env.DVC_GLOBAL_CONFIG_DIR) or platformdirs.user_config_dir(
        APPNAME, APPAUTHOR
    )

Common Errors

Error Message Cause Solution
Studio authentication fails silently `DVC_STUDIO_TOKEN` not set or invalid `export DVC_STUDIO_TOKEN="<valid-token>"`
Progress bars not showing in CI TTY not detected in non-interactive shells `export DVC_IGNORE_ISATTY=1`
Daemon spawns recursively `DVC_DAEMON` flag not propagated DVC sets this automatically; do not override
Wrong config directory used Directory override env var pointing to wrong path Verify `DVC_GLOBAL_CONFIG_DIR` or `DVC_SYSTEM_CONFIG_DIR` values

Compatibility Notes

  • CI/CD environments: Set `DVC_NO_ANALYTICS=1` and `DVC_IGNORE_ISATTY=1` for headless operation. The updater check is automatically skipped when `CI` environment variable is set.
  • Docker containers: Use `DVC_GLOBAL_CONFIG_DIR` and `DVC_SITE_CACHE_DIR` to control config and cache locations within containers.
  • Experiment workers: The variables `DVC_EXP_BASELINE_REV`, `DVC_EXP_NAME`, and `DVC_ROOT` are set automatically by DVC when running experiments. Do not override these manually.
  • Pager: `DVC_PAGER` overrides the standard `PAGER` environment variable for DVC output only.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment