Edit on GitHub


Return the relative path to the root directory of the DVC project.


usage: dvc root [-h] [-q | -v]


Returns the path to the root directory of the DVC project, relative to the current working directory. dvc root is useful for referencing a file in another directory when working in a subdirectory of the project.

Use this command to build fixed paths to dependencies, files, or stage outputs. This is useful when creating shell scripts that generate dvc.yaml files programmatically or with the dvc stage add helper.


  • -h, --help - prints the usage/help message, and exit.

  • -q, --quiet - do not write anything to standard output. Exit with 0 if no problems arise, otherwise 1.

  • -v, --verbose - displays detailed tracing information.


Basic demonstration:

$ dvc root

$ mkdir subdir
$ cd subdir
$ dvc root

Example: Referencing fixed paths in other commands

When working in a subdirectory of a DVC project, simplify file references by making all paths relative to the root directory.

$ dvc root

$ dvc stage add -d $(dvc root)/data/file.cvs ... \
      python $(dvc root)/scripts/something.py

The same can be applied to non-DVC commands:

$ dvc root

$ tree $(dvc root)/data/
├── data.xml
├── data.xml.dvc

🐛 Found an issue? Let us know! Or fix it:

Edit on GitHub

Have a question? Join our chat, we will help you:

Discord Chat