dvc.org icon indicating copy to clipboard operation
dvc.org copied to clipboard

ref: explain relative path behavior for all config values

Open pmrowla opened this issue 4 years ago • 3 comments

In the docs for config we specifically note that for cache.dir

A correct value is either an absolute path, or a path relative to the config file location. The default value is cache, that resolves to .dvc/cache (relative to the project config file location).

It's unclear that:

  1. This relpath behavior actually applies to all config entries that take paths - including remote options like credentialpath. (We don't mention this anywhere on any of the remote docs pages, and all of the examples on the remote pages only use absolute paths)
  2. Paths manually written to the actual config file should be relative to the config directory (this also means --global and --system paths should be relative to the global/system config directory and not relative to .dvc/)
  3. Paths specified on the command line via dvc config .../dvc remote modify ... should still be relative to the users current working directory

DVC automatically does the adjustment to convert whatever path specified ends up relative to the config directory like so:

$ dvc config cache.dir relative-dir
$ cat .dvc/config
[cache]
    dir = ../relative-dir
$ dvc config cache.dir ../relative-dir
$ cat .dvc/config
[cache]
    dir = ../../relative-dir
$ dvc config --global cache.dir ./relative-dir
$ cat ~/Library/Application\ Support/dvc/config
[cache]
    dir = ../../../git/example-get-started/relative-dir

discord context: https://discord.com/channels/485586884165107732/485596304961962003/841840114585698314

pmrowla avatar May 12 '21 01:05 pmrowla

It's unclear that: ... 2. Paths manually written to the actual config file should be relative to the config directory (this also means --global and --system

I think that "A correct value is ... a path relative to the config file location" covers that. We should probably emphasize that can mean system/global though.

  1. Paths specified on the command line ... should still be relative to the users current working directory

Wait, so is the info in cache.dir wrong? I.e. the default value couldn't be just cache (that would be converted to ../cache in .dvc/config

DVC automatically does the adjustment to convert whatever path specified ends up relative to the config directory

So is dvc cache dir basically no longer needed?

Need to try this ⌛

jorgeorpinel avatar May 13 '21 02:05 jorgeorpinel

Wait, so is the info in cache.dir wrong? I.e. the default value couldn't be just cache

Yup

$ dvc config cache.dir cache
$ cat .dvc/config
[cache]
    dir = ../cache

is dvc cache dir basically no longer needed?

I tried it and it seems so. It has the exact same result as dvc config cache.dir. When did this change? 🤷 I opened https://github.com/iterative/dvc/issues/6003

jorgeorpinel avatar May 13 '21 02:05 jorgeorpinel

@pmrowla feel free to chime in https://github.com/iterative/dvc/issues/6003 to try and move this along. Thanks

jorgeorpinel avatar May 19 '21 16:05 jorgeorpinel